C# formatting
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using GameList.Infrastructure;
|
||||
@@ -7,10 +6,7 @@ using GameList.Endpoints;
|
||||
using GameList.Tests.Support;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using System.Text.Json;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
@@ -36,9 +32,8 @@ public class HelperTests
|
||||
File.WriteAllText(index, "<meta name=\"app-base\" content=\"\">");
|
||||
|
||||
var env = new FakeEnv { WebRootPath = webRoot };
|
||||
var method = typeof(Program).GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
.First(m => m.Name.Contains("UpdateIndexMetaBase"));
|
||||
method.Invoke(null, new object?[] { env, "/pick" });
|
||||
var method = typeof(Program).GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).First(m => m.Name.Contains("UpdateIndexMetaBase"));
|
||||
method.Invoke(null, [env, "/pick"]);
|
||||
|
||||
var text = File.ReadAllText(index);
|
||||
Assert.Contains("content=\"/pick\"", text);
|
||||
@@ -53,9 +48,8 @@ public class HelperTests
|
||||
File.WriteAllText(index, "<html></html>");
|
||||
|
||||
var env = new FakeEnv { WebRootPath = webRoot };
|
||||
var method = typeof(Program).GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
.First(m => m.Name.Contains("UpdateIndexMetaBase"));
|
||||
method.Invoke(null, new object?[] { env, "/pick" });
|
||||
var method = typeof(Program).GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).First(m => m.Name.Contains("UpdateIndexMetaBase"));
|
||||
method.Invoke(null, [env, "/pick"]);
|
||||
|
||||
Assert.Equal("<html></html>", File.ReadAllText(index));
|
||||
}
|
||||
@@ -76,14 +70,15 @@ public class HelperTests
|
||||
if (req.Method == HttpMethod.Head)
|
||||
{
|
||||
var resp = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
resp.Content = new ByteArrayContent(Array.Empty<byte>());
|
||||
resp.Content = new ByteArrayContent([]);
|
||||
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
|
||||
resp.Content.Headers.ContentLength = 100;
|
||||
return resp;
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new ByteArrayContent(Array.Empty<byte>())
|
||||
Content = new ByteArrayContent([])
|
||||
{
|
||||
Headers =
|
||||
{
|
||||
@@ -125,7 +120,7 @@ public class HelperTests
|
||||
handler.SetResponder(_ =>
|
||||
{
|
||||
var resp = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
resp.Content = new ByteArrayContent(System.Text.Encoding.UTF8.GetBytes("not image"));
|
||||
resp.Content = new ByteArrayContent("not image"u8.ToArray());
|
||||
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");
|
||||
resp.Content.Headers.ContentLength = 9;
|
||||
return resp;
|
||||
@@ -138,7 +133,7 @@ public class HelperTests
|
||||
[Fact]
|
||||
public void Link_root_helpers_handle_groups()
|
||||
{
|
||||
var roots = EndpointHelpers.BuildLinkRoots(new[] { (1, (int?)null), (2, 1), (3, (int?)null) });
|
||||
var roots = EndpointHelpers.BuildLinkRoots([(1, null), (2, 1), (3, null)]);
|
||||
Assert.Equal(1, roots[1]);
|
||||
Assert.Equal(1, roots[2]);
|
||||
Assert.Equal(3, roots[3]);
|
||||
@@ -162,9 +157,9 @@ public class HelperTests
|
||||
{
|
||||
var parentMap = new Dictionary<int, int?>
|
||||
{
|
||||
{1, 2},
|
||||
{2, 3},
|
||||
{3, 1}
|
||||
{ 1, 2 },
|
||||
{ 2, 3 },
|
||||
{ 3, 1 }
|
||||
};
|
||||
|
||||
var root = EndpointHelpers.FindRootId(1, parentMap);
|
||||
@@ -174,16 +169,13 @@ public class HelperTests
|
||||
[Fact]
|
||||
public async Task Global_exception_handler_returns_json_error()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory().WithWebHostBuilder(builder =>
|
||||
await using var factory = new TestWebApplicationFactory().WithWebHostBuilder(builder =>
|
||||
{
|
||||
builder.Configure(app =>
|
||||
{
|
||||
app.UseGlobalExceptionLogging();
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapGet("/boom", _ => throw new InvalidOperationException("boom"));
|
||||
});
|
||||
app.UseEndpoints(endpoints => { endpoints.MapGet("/boom", _ => throw new InvalidOperationException("boom")); });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user