From 4e9130cd25a8fa5d5bbc549c749867225436c8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20B=C4=85czek?= <74410956+kamilbaczek@users.noreply.github.com> Date: Sat, 7 Dec 2024 23:04:23 +0100 Subject: [PATCH] fix: fix warning for not serialable theory by chaning to fact --- .../GenerateNewPassesPerMonthReportTests.cs | 8 +- .../TestData/ReportTestCases.cs | 80 +++++++++++++------ 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/GenerateNewPassesPerMonthReportTests.cs b/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/GenerateNewPassesPerMonthReportTests.cs index c233eac0..75ea4578 100644 --- a/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/GenerateNewPassesPerMonthReportTests.cs +++ b/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/GenerateNewPassesPerMonthReportTests.cs @@ -26,12 +26,12 @@ public GenerateNewPassesPerMonthReportTests(FitnetWebApplicationFactory _applicationHttpClient = _applicationInMemoryFactory.CreateClient(); } - [Theory] - [ClassData(typeof(ReportTestCases))] - internal async Task Given_valid_generate_new_report_request_Then_should_return_correct_data(List passRegistrationDateRanges) + [Fact] + internal async Task Given_valid_generate_new_report_request_Then_should_return_correct_data() { // Arrange - await RegisterPasses(passRegistrationDateRanges); + var reportTestData = ReportTestCases.GetAnnualPassesData(); + await RegisterPasses(reportTestData); // Act var getReportResult = await _applicationHttpClient.GetAsync(ReportsApiPaths.GenerateNewReport); diff --git a/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/TestData/ReportTestCases.cs b/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/TestData/ReportTestCases.cs index 3e88965b..8481cc53 100644 --- a/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/TestData/ReportTestCases.cs +++ b/Chapter-2-modules-separation/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GenerateNewPassesPerMonthReport/TestData/ReportTestCases.cs @@ -1,31 +1,61 @@ namespace EvolutionaryArchitecture.Fitnet.Reports.IntegrationTests.GenerateNewPassesPerMonthReport.TestData; -internal sealed class ReportTestCases : IEnumerable +internal static class ReportTestCases { internal static DateTimeOffset FakeNowDate = new(2021, 1, 1, 0, 0, 0, TimeSpan.Zero); - public IEnumerator GetEnumerator() - { - yield return new object[] - { - new List - { - new(new DateTimeOffset(FakeNowDate.Year, 1, 3, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 1, 10 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 1, 5, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 1, 20 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 2, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 2, 28 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 3, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 3, 31 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 4, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 4, 30 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 5, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 5, 31 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 6, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 6, 30 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 7, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 7, 31 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 8, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 8, 31 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 9, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 9, 30 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 10, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 10, 31 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 11, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 11, 30 ,1, 1, 1,1, TimeSpan.Zero)), - new(new DateTimeOffset(FakeNowDate.Year, 12, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 12, 31 ,1, 1, 1,1, TimeSpan.Zero)) - } - }; - } - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + internal static List GetAnnualPassesData() => + [ + new( + new DateTimeOffset(FakeNowDate.Year, 1, 3, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 1, 10, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 1, 5, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 1, 20, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 2, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 2, 28, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 3, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 3, 31, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 4, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 4, 30, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 5, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 5, 31, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 6, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 6, 30, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 7, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 7, 31, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 8, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 8, 31, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 9, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 9, 30, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 10, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 10, 31, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 11, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 11, 30, 1, 1, 1, TimeSpan.Zero)), + + new( + new DateTimeOffset(FakeNowDate.Year, 12, 1, 1, 1, 1, TimeSpan.Zero), + new DateTimeOffset(FakeNowDate.Year, 12, 31, 1, 1, 1, TimeSpan.Zero)) + ]; }