-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDMS-200 switches country ched searching to use country of origin & r…
…efactoring of test fixtures (#40) * CDMS-200 switches country ched searching to use country of origin CDMS-200 Refactored no match tests to re-use code Refactoring Test Fixtures Switched Analytics MaxVersion tests to use new fixtures Some small refactoring to remove some generics CDMS-200 adds additional decision tests, moves alvs decision check analytics into context so it appears in audit entry Refactoring fixtures Refactoring fixtures * Finished refactoring of BaseTest class :fingers-crossed
- Loading branch information
1 parent
4f680ac
commit f50eea6
Showing
62 changed files
with
1,114 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,159 @@ | ||
using Btms.Common.Extensions; | ||
using Btms.Model.Ipaffs; | ||
using FluentAssertions; | ||
using TestDataGenerator.Scenarios; | ||
using TestGenerator.IntegrationTesting.Backend; | ||
using TestGenerator.IntegrationTesting.Backend.Extensions; | ||
using TestGenerator.IntegrationTesting.Backend.Fixtures; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
using Btms.Analytics.Tests.Fixtures; | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Analytics.Tests; | ||
|
||
[Collection(nameof(BasicSampleDataTestCollection))] | ||
public class MovementsByMaxVersionTests( | ||
BasicSampleDataTestFixture basicSampleDataTestFixture, | ||
ITestOutputHelper testOutputHelper) | ||
// [Collection(nameof(BasicSampleDataTestCollection))] | ||
// public class MovementsByMaxVersionTests( | ||
// BasicSampleDataTestFixture basicSampleDataTestFixture, | ||
// ITestOutputHelper testOutputHelper) | ||
public class MovementsByMaxVersionTests(ITestOutputHelper output) | ||
: BaseTest<CrNoMatchSingleItemWithDecisionScenarioGenerator>(output) | ||
{ | ||
// [Fact] | ||
// public async Task WhenCalledLastWeek_ReturnExpectedAggregation() | ||
// { | ||
// testOutputHelper.WriteLine("Querying for aggregated data"); | ||
// var result = (await basicSampleDataTestFixture.GetMovementsAggregationService(testOutputHelper) | ||
// .ByStatus(DateTime.Today.WeekAgo(), DateTime.Today.Tomorrow())); | ||
// | ||
// testOutputHelper.WriteLine("{0} aggregated items found", result.Values.Count); | ||
// | ||
// result.Values.Count.Should().Be(2); | ||
// result.Values.Keys.Order().Should().Equal("Linked", "Not Linked"); | ||
// } | ||
// | ||
// [Fact] | ||
// public async Task WhenCalledLast48Hours_ReturnExpectedAggregation() | ||
// { | ||
// testOutputHelper.WriteLine("Querying for aggregated data"); | ||
// var result = (await basicSampleDataTestFixture.GetMovementsAggregationService(testOutputHelper) | ||
// .ByStatus(DateTime.Now.NextHour().AddDays(-2), DateTime.Now.NextHour())); | ||
// | ||
// testOutputHelper.WriteLine($"{result.Values.Count} aggregated items found"); | ||
// | ||
// result.Values.Count.Should().Be(2); | ||
// result.Values.Keys.Order().Should().Equal("Linked", "Not Linked"); | ||
// } | ||
// | ||
// [Fact] | ||
// public async Task WhenCalledWithTimePeriodYieldingNoResults_ReturnEmptyAggregation() | ||
// { | ||
// testOutputHelper.WriteLine("Querying for aggregated data"); | ||
// var result = (await basicSampleDataTestFixture.GetMovementsAggregationService(testOutputHelper) | ||
// .ByStatus(DateTime.MaxValue.AddDays(-1), DateTime.MaxValue)); | ||
// | ||
// testOutputHelper.WriteLine($"{result.Values.Count} aggregated items found"); | ||
// | ||
// result.Values.Count.Should().Be(2); | ||
// result.Values.Keys.Order().Should().Equal("Linked", "Not Linked"); | ||
// } | ||
|
||
[Fact] | ||
public async Task WhenCalled_ReturnsResults() | ||
{ | ||
TestOutputHelper.WriteLine("Querying for aggregated data"); | ||
|
||
var result = await BackendFixture | ||
.BtmsClient | ||
.GetAnalyticsDashboard(["movementsByMaxEntryVersion"], | ||
dateFrom:DateTime.Today.AddDays(-1), | ||
dateTo:DateTime.Today.AddDays(1)); | ||
|
||
TestOutputHelper.WriteLine($"{result.StatusCode} status"); | ||
result.IsSuccessStatusCode.Should().BeTrue(result.StatusCode.ToString()); | ||
|
||
var charts = await result.ToJsonDictionary(); | ||
|
||
TestOutputHelper.WriteLine($"movementsByMaxEntryVersion keys : {charts["movementsByMaxEntryVersion"].GetKeys()}"); | ||
TestOutputHelper.WriteLine($"result keys : {charts["movementsByMaxEntryVersion"]["values"]!.GetKeys()}"); | ||
|
||
charts["movementsByMaxEntryVersion"]["values"]! | ||
.GetKeys() | ||
.Length.Should().Be(1); | ||
|
||
var val = charts["movementsByMaxEntryVersion"]["values"]!["1"]! | ||
.GetValue<int>() | ||
.Should() | ||
.Be(1); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenCalledWithChedType_ReturnsResults() | ||
{ | ||
testOutputHelper.WriteLine("Querying for aggregated data"); | ||
var result = (await basicSampleDataTestFixture.GetMovementsAggregationService(testOutputHelper) | ||
.ByMaxVersion(DateTime.Now.NextHour().AddDays(-2), DateTime.Now.NextHour(), chedTypes: [ImportNotificationTypeEnum.Cveda])); | ||
TestOutputHelper.WriteLine("Querying for aggregated data"); | ||
|
||
var result = await BackendFixture | ||
.BtmsClient | ||
.GetAnalyticsDashboard(["movementsByMaxEntryVersion"], | ||
dateFrom:DateTime.Today.AddDays(-1), | ||
dateTo:DateTime.Today.AddDays(1), | ||
chedTypes: [ImportNotificationTypeEnum.Cvedp]); | ||
|
||
TestOutputHelper.WriteLine($"{result.StatusCode} status"); | ||
result.IsSuccessStatusCode.Should().BeTrue(result.StatusCode.ToString()); | ||
|
||
var charts = await result.ToJsonDictionary(); | ||
|
||
TestOutputHelper.WriteLine($"movementsByMaxEntryVersion keys : {charts["movementsByMaxEntryVersion"].GetKeys()}"); | ||
TestOutputHelper.WriteLine($"result keys : {charts["movementsByMaxEntryVersion"]["values"]!.GetKeys()}"); | ||
|
||
charts["movementsByMaxEntryVersion"]["values"]! | ||
.GetKeys() | ||
.Length.Should().Be(1); | ||
|
||
var val = charts["movementsByMaxEntryVersion"]["values"]!["1"]! | ||
.GetValue<int>() | ||
.Should() | ||
.Be(1); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenCalledWithWrongChedType_ReturnsResults() | ||
{ | ||
TestOutputHelper.WriteLine("Querying for aggregated data"); | ||
|
||
testOutputHelper.WriteLine($"{result.Values.Count} aggregated items found"); | ||
var result = await BackendFixture | ||
.BtmsClient | ||
.GetAnalyticsDashboard(["movementsByMaxEntryVersion"], | ||
dateFrom:DateTime.Today.AddDays(-1), | ||
dateTo:DateTime.Today.AddDays(1), | ||
chedTypes: [ImportNotificationTypeEnum.Cveda]); | ||
|
||
TestOutputHelper.WriteLine($"{result.StatusCode} status"); | ||
result.IsSuccessStatusCode.Should().BeTrue(result.StatusCode.ToString()); | ||
|
||
var charts = await result.ToJsonDictionary(); | ||
|
||
result.Values.Count.Should().Be(2); | ||
TestOutputHelper.WriteLine($"movementsByMaxEntryVersion keys : {charts["movementsByMaxEntryVersion"].GetKeys()}"); | ||
TestOutputHelper.WriteLine($"result keys : {charts["movementsByMaxEntryVersion"]["values"]!.GetKeys()}"); | ||
|
||
charts["movementsByMaxEntryVersion"]["values"]! | ||
.GetKeys() | ||
.Length.Should().Be(0); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenCalledWithCountry_ReturnsResults() | ||
{ | ||
testOutputHelper.WriteLine("Querying for aggregated data"); | ||
var result = (await basicSampleDataTestFixture.GetMovementsAggregationService(testOutputHelper) | ||
.ByMaxVersion(DateTime.Now.NextHour().AddDays(-2), DateTime.Now.NextHour(), country: "AL")); | ||
TestOutputHelper.WriteLine("Querying for aggregated data"); | ||
|
||
var result = await BackendFixture | ||
.BtmsClient | ||
.GetAnalyticsDashboard(["movementsByMaxEntryVersion"], | ||
dateFrom:DateTime.Today.AddDays(-1), | ||
dateTo:DateTime.Today.AddDays(1), | ||
country:"FR"); | ||
|
||
TestOutputHelper.WriteLine($"{result.StatusCode} status"); | ||
result.IsSuccessStatusCode.Should().BeTrue(result.StatusCode.ToString()); | ||
|
||
var charts = await result.ToJsonDictionary(); | ||
|
||
TestOutputHelper.WriteLine($"movementsByMaxEntryVersion keys : {charts["movementsByMaxEntryVersion"].GetKeys()}"); | ||
TestOutputHelper.WriteLine($"result keys : {charts["movementsByMaxEntryVersion"]["values"]!.GetKeys()}"); | ||
|
||
charts["movementsByMaxEntryVersion"]["values"]! | ||
.GetKeys() | ||
.Length.Should().Be(1); | ||
|
||
var val = charts["movementsByMaxEntryVersion"]["values"]!["1"]! | ||
.GetValue<int>() | ||
.Should() | ||
.Be(1); | ||
} | ||
|
||
|
||
[Fact] | ||
public async Task WhenCalledWithWrongCountry_ReturnsResults() | ||
{ | ||
TestOutputHelper.WriteLine("Querying for aggregated data"); | ||
|
||
testOutputHelper.WriteLine($"{result.Values.Count} aggregated items found"); | ||
var result = await BackendFixture | ||
.BtmsClient | ||
.GetAnalyticsDashboard(["movementsByMaxEntryVersion"], | ||
dateFrom:DateTime.Today.AddDays(-1), | ||
dateTo:DateTime.Today.AddDays(1), | ||
country:"ES"); | ||
|
||
TestOutputHelper.WriteLine($"{result.StatusCode} status"); | ||
result.IsSuccessStatusCode.Should().BeTrue(result.StatusCode.ToString()); | ||
|
||
result.Values.Count.Should().Be(1); | ||
var charts = await result.ToJsonDictionary(); | ||
|
||
TestOutputHelper.WriteLine($"movementsByMaxEntryVersion keys : {charts["movementsByMaxEntryVersion"].GetKeys()}"); | ||
TestOutputHelper.WriteLine($"result keys : {charts["movementsByMaxEntryVersion"]["values"]!.GetKeys()}"); | ||
|
||
charts["movementsByMaxEntryVersion"]["values"]! | ||
.GetKeys() | ||
.Length.Should().Be(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.