git checkout -b feature-branch
This commit is contained in:
@ -15,7 +15,7 @@ public class UnitTestClientSettingsController
|
||||
private static ILogger _Logger;
|
||||
private static string _ControllerName;
|
||||
private static TestContext _TestContext;
|
||||
private static WebApplicationFactory<Viewer.Program> _WebApplicationFactory;
|
||||
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
|
||||
|
||||
#pragma warning restore
|
||||
|
||||
@ -24,8 +24,8 @@ public class UnitTestClientSettingsController
|
||||
{
|
||||
_TestContext = testContext;
|
||||
_Logger = Log.ForContext<UnitTestClientSettingsController>();
|
||||
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
|
||||
_ControllerName = nameof(Viewer.ApiControllers.ClientSettingsController)[..^10];
|
||||
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||
_ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10];
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -56,10 +56,11 @@ public class UnitTestClientSettingsController
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
|
||||
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
|
||||
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
|
||||
string result = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
string json = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
httpClient.Dispose();
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue(result != "[]");
|
||||
Assert.IsNotNull(json);
|
||||
Assert.IsTrue(json != "[]");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
@ -83,9 +84,10 @@ public class UnitTestClientSettingsController
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
|
||||
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
|
||||
Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
|
||||
string result = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
string json = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
httpClient.Dispose();
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(json);
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user