Template
chore: deploy initial code base
This commit is contained in:
+167
@@ -0,0 +1,167 @@
|
||||
using Strata.ApiCommunication.Http;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Api.Test.Integration.Tests
|
||||
{
|
||||
[TestFixture(Category = "Integration")]
|
||||
public class TestOpportunityController : ApiTestBase
|
||||
{
|
||||
[TestCaseSource(nameof(OpportunityControllerTestCases))]
|
||||
public async Task OpportunityControllerTest(string testName, string url, string sortField, object? filters, bool exportable)
|
||||
{
|
||||
// arrange
|
||||
var configurations = await GetConfigurations();
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First();
|
||||
var configurationGuid = configuration.ConfigurationGuid;
|
||||
sortField = sortField ?? "identifiedSavings";
|
||||
filters = filters ?? new
|
||||
{
|
||||
configurationGuid,
|
||||
opportunityTypes = Array.Empty<string>(),
|
||||
identifiedSavings = null as object,
|
||||
viewVisible = true,
|
||||
excludeInitiatives = false,
|
||||
opportunitySearch = ""
|
||||
};
|
||||
|
||||
var data = new
|
||||
{
|
||||
pagingOptions = new
|
||||
{
|
||||
sortField,
|
||||
sortOrder = "Desc",
|
||||
first = 0,
|
||||
rows = 25
|
||||
},
|
||||
filters,
|
||||
};
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
await request.SetContentAsJsonAsync(data);
|
||||
|
||||
// act
|
||||
var response = await HttpClient.SendAsync(request, CancellationToken.None);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
// asert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
response.AssertIsValid();
|
||||
});
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(OpportunityControllerTestCases))]
|
||||
public async Task OpportunityControllerFilterTest(string testName, string url, string sortField, object? filters, bool exportable)
|
||||
{
|
||||
// arrange
|
||||
var configurations = await GetConfigurations();
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First();
|
||||
var configurationGuid = configuration.ConfigurationGuid;
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url + $"/{configurationGuid}/filter-options");
|
||||
|
||||
// act
|
||||
var response = await HttpClient.SendAsync(request, CancellationToken.None);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
// asert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
response.AssertIsValid();
|
||||
});
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(OpportunityControllerTestCases))]
|
||||
public async Task OpportunityControllerFilteExportTest(string testName, string url, string sortField, object? filters, bool exportable)
|
||||
{
|
||||
if (!exportable) { Assert.Ignore(); return; }
|
||||
// arrange
|
||||
var configurations = await GetConfigurations();
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First();
|
||||
var configurationGuid = configuration.ConfigurationGuid;
|
||||
sortField = sortField ?? "identifiedSavings";
|
||||
filters = filters ?? new
|
||||
{
|
||||
configurationGuid,
|
||||
opportunityTypes = Array.Empty<string>(),
|
||||
identifiedSavings = null as object,
|
||||
viewVisible = true,
|
||||
excludeInitiatives = false,
|
||||
opportunitySearch = ""
|
||||
};
|
||||
|
||||
var data = new
|
||||
{
|
||||
pagingOptions = new
|
||||
{
|
||||
sortField,
|
||||
sortOrder = "Desc",
|
||||
first = 0,
|
||||
rows = 25
|
||||
},
|
||||
filters,
|
||||
};
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url + $"/export");
|
||||
await request.SetContentAsJsonAsync(data);
|
||||
|
||||
// act
|
||||
var response = await HttpClient.SendAsync(request, CancellationToken.None);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
// asert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
response.AssertIsValid(exportable);
|
||||
});
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> OpportunityControllerTestCases()
|
||||
{
|
||||
yield return new TestCaseData("all opportunities", "/api/v1/all-opportunities", null, new
|
||||
{
|
||||
configurationGuid = "aa4cba4f-2506-462c-8e34-c45b21653988"
|
||||
}, true).SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("charge code opportunities", "/api/v1/charge-code-opps", null, new
|
||||
{
|
||||
configurationGuid = "aa4cba4f-2506-462c-8e34-c45b21653988",
|
||||
opportunityTypes = Array.Empty<string>(),
|
||||
identifiedSavings = null as object,
|
||||
viewVisible = true,
|
||||
excludeInitiatives = false,
|
||||
opportunitySearch = ""
|
||||
}, true).SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("encounter opportunities", "/api/v1/encounter-opportunities", null, null, true)
|
||||
.SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("free form opportunities", "/api/v1/free-form-opportunities", null, null, true)
|
||||
.SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("general ledger opportunities", "/api/v1/general-ledger-opportunities", null, null, true)
|
||||
.SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("payroll opportunities", "/api/v1/payroll-opportunities", null, null, true)
|
||||
.SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("qvi opportunities", "/api/v1/quality-variation-item-opportunities", null, null, true)
|
||||
.SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("qvi breakdowns", "/api/v1/quality-variation-item-breakdowns", "identifiedSavingsTotal", new
|
||||
{
|
||||
exportFiltered = false,
|
||||
configurationGuid = "aa4cba4f-2506-462c-8e34-c45b21653988",
|
||||
identifiedSavings = 0,
|
||||
breakdownIds = Array.Empty<string>(),
|
||||
qualityVariationCases = 0
|
||||
}, false).SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("qvi events", "/api/v1/quality-variation-item-events", "identifiedSavingsTotal", new
|
||||
{
|
||||
configurationGuid = "aa4cba4f-2506-462c-8e34-c45b21653988"
|
||||
}, false).SetName("{m} {0}");
|
||||
|
||||
yield return new TestCaseData("variation opportunities", "/api/v1/variation-opportunities", null, new
|
||||
{
|
||||
configurationGuid = "aa4cba4f-2506-462c-8e34-c45b21653988"
|
||||
}, true).SetName("{m} {0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user