Mock json files
This commit is contained in:
@ -59,11 +59,11 @@ public class UnitTestToolTypesController
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(IndexApi)}.json"), json);
|
||||
Result<ToolTypeNameId[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeNameId[]>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.IsFalse(result.Results.All(l => l.ID == 0));
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
@ -88,12 +88,12 @@ public class UnitTestToolTypesController
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetToolTypeMetadataApi)}.json"), json);
|
||||
Result<ToolTypeMetadataResult>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeMetadataResult>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsNotNull(result.Results.Metadata);
|
||||
Assert.IsTrue(result.Results.Metadata.Any());
|
||||
Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0));
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
@ -116,10 +116,10 @@ public class UnitTestToolTypesController
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers");
|
||||
Result<DataTable>? result = System.Text.Json.JsonSerializer.Deserialize<Result<DataTable>>(json);
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeadersApi)}.json"), json);
|
||||
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsNotNull(result.Results.Rows.Count > 0);
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
@ -142,10 +142,10 @@ public class UnitTestToolTypesController
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headertitles");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderTitlesApi)}.json"), json);
|
||||
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
@ -168,10 +168,10 @@ public class UnitTestToolTypesController
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderFieldsApi)}.json"), json);
|
||||
Result<ColumnValue[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ColumnValue[]>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
@ -194,10 +194,10 @@ public class UnitTestToolTypesController
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/data");
|
||||
Result<DataTable>? result = System.Text.Json.JsonSerializer.Deserialize<Result<DataTable>>(json);
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetDataApi)}.json"), json);
|
||||
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsNotNull(result.Results.Rows.Count > 0);
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user