From 04531e834e528b5777f49d4a79e5e69ed868f603 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:47:24 +0000 Subject: [PATCH 1/2] Bump xunit from 2.7.1 to 2.8.1 Bumps [xunit](https://github.com/xunit/xunit) from 2.7.1 to 2.8.1. - [Commits](https://github.com/xunit/xunit/compare/2.7.1...2.8.1) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj b/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj index 09e0a3c9d..2aa23171a 100644 --- a/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj +++ b/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj @@ -31,7 +31,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 53f6e8269376769100ca1b99603cc694c4e96ac3 Mon Sep 17 00:00:00 2001 From: Martyn Whitwell Date: Wed, 19 Jun 2024 11:59:56 +0100 Subject: [PATCH 2/2] update async void to Task --- .../Auth/ApiClientHandlerTests.cs | 59 ++--- .../Contracts/ApplyCandidateApiTests.cs | 3 +- .../Contracts/TeacherTrainingAdviserTests.cs | 7 +- .../TeachingEventsControllerTests.cs | 8 +- .../Controllers/LookupItemsControllerTests.cs | 5 +- .../Controllers/OperationsControllerTests.cs | 93 +++---- .../PickListItemsControllerTests.cs | 47 ++-- .../PrivacyPoliciesControllerTests.cs | 11 +- .../Jobs/ApplyBackfillJobTests.cs | 5 +- .../Jobs/ApplySyncJobTests.cs | 11 +- .../Jobs/CrmSyncJobTests.cs | 7 +- .../Jobs/LocationSyncJobTests.cs | 47 ++-- .../RequestResponseLoggingMiddlewareTests.cs | 12 +- .../Services/NotifyServiceTests.cs | 4 +- .../Services/PaginatorClientTests.cs | 21 +- .../Services/StoreTests.cs | 232 +++++++++--------- 16 files changed, 292 insertions(+), 280 deletions(-) diff --git a/GetIntoTeachingApiTests/Auth/ApiClientHandlerTests.cs b/GetIntoTeachingApiTests/Auth/ApiClientHandlerTests.cs index 552de9a79..20eb12e03 100644 --- a/GetIntoTeachingApiTests/Auth/ApiClientHandlerTests.cs +++ b/GetIntoTeachingApiTests/Auth/ApiClientHandlerTests.cs @@ -1,4 +1,4 @@ -using System.Security.Claims; +using System.Security.Claims; using System.Text.Encodings.Web; using FluentAssertions; using GetIntoTeachingApi.Auth; @@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Moq; +using System.Threading.Tasks; using Xunit; namespace GetIntoTeachingApiTests.Auth @@ -44,7 +45,7 @@ public ApiClientHandlerTests() [InlineData("", false)] [InlineData(" ", false)] [InlineData(null, false)] - public async void InitializeAsync_WithApiClient_AuthenticatesCorrectly(string authHeaderValue, bool expected) + public async Task InitializeAsync_WithApiClient_AuthenticatesCorrectly(string authHeaderValue, bool expected) { var client = new Client() { Name = "Admin", Description = "Admin account", Role = "Service", ApiKey = "api_key", ApiKeyPrefix = "ADMIN" }; _mockClientManager.Setup(m => m.GetClient(client.ApiKey)).Returns(client); @@ -65,37 +66,37 @@ public async void InitializeAsync_WithApiClient_AuthenticatesCorrectly(string au } } - [Theory] - [InlineData("Bearer ", "")] - [InlineData("Bearer ", null)] - [InlineData("Bearer ", " ")] - [InlineData("Bearer ", " ")] - [InlineData("Bearer", "")] - [InlineData("Bearer", null)] - [InlineData("Bearer", " ")] - [InlineData("", "")] - [InlineData("", null)] - [InlineData(" ", " ")] - [InlineData(" ", "")] - [InlineData(" ", null)] - public async void InitializeAsync_EmptyOrNullHeaderAndApiKey_ReturnsUnauthorized(string authHeaderValue, string apiKey) - { + [Theory] + [InlineData("Bearer ", "")] + [InlineData("Bearer ", null)] + [InlineData("Bearer ", " ")] + [InlineData("Bearer ", " ")] + [InlineData("Bearer", "")] + [InlineData("Bearer", null)] + [InlineData("Bearer", " ")] + [InlineData("", "")] + [InlineData("", null)] + [InlineData(" ", " ")] + [InlineData(" ", "")] + [InlineData(" ", null)] + public async Task InitializeAsync_EmptyOrNullHeaderAndApiKey_ReturnsUnauthorized(string authHeaderValue, string apiKey) + { var client = new Client() { Name = "Admin", Description = "Admin account", Role = "Admin", ApiKey = apiKey, ApiKeyPrefix = "ADMIN" }; - _mockClientManager.Setup(m => m.GetClient(client.ApiKey)).Returns(client); - - var context = new DefaultHttpContext(); - context.Request.Headers.Add("Authorization", authHeaderValue); - var scheme = new AuthenticationScheme("ApiClientHandler", null, typeof(ApiClientHandler)); - await _handler.InitializeAsync(scheme, context); - - var result = await _handler.AuthenticateAsync(); - - result.Succeeded.Should().BeFalse(); - result.Failure.Message.Should().Be("API key is not valid"); + _mockClientManager.Setup(m => m.GetClient(client.ApiKey)).Returns(client); + + var context = new DefaultHttpContext(); + context.Request.Headers.Add("Authorization", authHeaderValue); + var scheme = new AuthenticationScheme("ApiClientHandler", null, typeof(ApiClientHandler)); + await _handler.InitializeAsync(scheme, context); + + var result = await _handler.AuthenticateAsync(); + + result.Succeeded.Should().BeFalse(); + result.Failure.Message.Should().Be("API key is not valid"); } [Fact] - public async void InitializeAsync_NoAuthorizationHeader_ReturnsUnauthorized() + public async Task InitializeAsync_NoAuthorizationHeader_ReturnsUnauthorized() { var context = new DefaultHttpContext(); var scheme = new AuthenticationScheme("ApiClientHandler", null, typeof(ApiClientHandler)); diff --git a/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs b/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs index 1aafd73bd..f237dbb3b 100644 --- a/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs +++ b/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs @@ -4,6 +4,7 @@ using GetIntoTeachingApiTests.Helpers; using Hangfire; using Newtonsoft.Json; +using System.Threading.Tasks; using Xunit; namespace GetIntoTeachingApiTests.Contracts @@ -17,7 +18,7 @@ public ApplyCandidateApiTests(DatabaseFixture databaseFixture) : base(databaseFi [Theory] [ContractTestInputs("./Contracts/Input/ApplyCandidateApi")] - public async void Contract(string scenario) + public async Task Contract(string scenario) { await Setup(); diff --git a/GetIntoTeachingApiTests/Contracts/TeacherTrainingAdviserTests.cs b/GetIntoTeachingApiTests/Contracts/TeacherTrainingAdviserTests.cs index 8ca6aace6..5982f5cfb 100644 --- a/GetIntoTeachingApiTests/Contracts/TeacherTrainingAdviserTests.cs +++ b/GetIntoTeachingApiTests/Contracts/TeacherTrainingAdviserTests.cs @@ -1,10 +1,11 @@ -using System; +using System; using System.Net; using System.Net.Http; using System.Text; using FluentAssertions; -using FluentAssertions.Json; +using FluentAssertions.Json; using GetIntoTeachingApiTests.Helpers; +using System.Threading.Tasks; using Xunit; namespace GetIntoTeachingApiTests.Contracts @@ -19,7 +20,7 @@ public TeacherTrainingAdviserTests(DatabaseFixture databaseFixture) [Theory] [ContractTestInputs("./Contracts/Input/TeacherTrainingAdviser")] - public async void Contract(string scenario) + public async Task Contract(string scenario) { await Setup(); diff --git a/GetIntoTeachingApiTests/Controllers/GetIntoTeaching/TeachingEventsControllerTests.cs b/GetIntoTeachingApiTests/Controllers/GetIntoTeaching/TeachingEventsControllerTests.cs index af9cc3eca..3e168865b 100644 --- a/GetIntoTeachingApiTests/Controllers/GetIntoTeaching/TeachingEventsControllerTests.cs +++ b/GetIntoTeachingApiTests/Controllers/GetIntoTeaching/TeachingEventsControllerTests.cs @@ -113,7 +113,7 @@ public void Search_SearchRequestIsDecoratedWithCommaSeparatedAttributeForArrayPr } [Fact] - public async void Search_InvalidRequest_RespondsWithValidationErrors() + public async Task Search_InvalidRequest_RespondsWithValidationErrors() { var request = new TeachingEventSearchRequest() { Postcode = null }; _controller.ModelState.AddModelError("Postcode", "Postcode must be specified."); @@ -126,7 +126,7 @@ public async void Search_InvalidRequest_RespondsWithValidationErrors() } [Fact] - public async void Search_ValidRequest_ReturnsTeachingEvents() + public async Task Search_ValidRequest_ReturnsTeachingEvents() { var request = new TeachingEventSearchRequest() { Postcode = "KY12 8FG" }; var metricCountBefore = _metrics.TeachingEventSearchResults.WithLabels(new[] { string.Empty, request.Radius.ToString() }).Count; @@ -146,7 +146,7 @@ public async void Search_ValidRequest_ReturnsTeachingEvents() } [Fact] - public async void Get_ReturnsTeachingEvent() + public async Task Get_ReturnsTeachingEvent() { var teachingEvent = new TeachingEvent() { ReadableId = "123" }; _mockStore.Setup(mock => mock.GetTeachingEventAsync(teachingEvent.ReadableId)).ReturnsAsync(teachingEvent); @@ -158,7 +158,7 @@ public async void Get_ReturnsTeachingEvent() } [Fact] - public async void Get_WithMissingEvent_ReturnsNotFound() + public async Task Get_WithMissingEvent_ReturnsNotFound() { _mockStore.Setup(mock => mock.GetTeachingEventAsync(It.IsAny())).ReturnsAsync(null as TeachingEvent); diff --git a/GetIntoTeachingApiTests/Controllers/LookupItemsControllerTests.cs b/GetIntoTeachingApiTests/Controllers/LookupItemsControllerTests.cs index a06ea51a5..28d787c28 100644 --- a/GetIntoTeachingApiTests/Controllers/LookupItemsControllerTests.cs +++ b/GetIntoTeachingApiTests/Controllers/LookupItemsControllerTests.cs @@ -11,6 +11,7 @@ using GetIntoTeachingApi.Attributes; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace GetIntoTeachingApiTests.Controllers { @@ -38,7 +39,7 @@ public void PrivateShortTermResponseCache_IsPresent() } [Fact] - public async void GetCountries_ReturnsAllCountriesSortedByCountryName() + public async Task GetCountries_ReturnsAllCountriesSortedByCountryName() { var mockCountries = MockCountries(); _mockStore.Setup(mock => mock.GetCountries()).Returns(mockCountries.AsAsyncQueryable()); @@ -51,7 +52,7 @@ public async void GetCountries_ReturnsAllCountriesSortedByCountryName() } [Fact] - public async void GetTeachingSubjects_ReturnsAllSubjectsSortedBySubjectName() + public async Task GetTeachingSubjects_ReturnsAllSubjectsSortedBySubjectName() { var mockSubjects = MockTeachingSubjects(); _mockStore.Setup(mock => mock.GetTeachingSubjects()).Returns(mockSubjects.AsAsyncQueryable()); diff --git a/GetIntoTeachingApiTests/Controllers/OperationsControllerTests.cs b/GetIntoTeachingApiTests/Controllers/OperationsControllerTests.cs index 1142d5963..0bb9a25e5 100644 --- a/GetIntoTeachingApiTests/Controllers/OperationsControllerTests.cs +++ b/GetIntoTeachingApiTests/Controllers/OperationsControllerTests.cs @@ -8,13 +8,14 @@ using GetIntoTeachingApi.Utils; using Moq; using Xunit; -using System; -using Microsoft.AspNetCore.Authorization; -using Hangfire; -using Hangfire.Common; -using GetIntoTeachingApi.Jobs; -using Hangfire.States; - +using System; +using Microsoft.AspNetCore.Authorization; +using Hangfire; +using Hangfire.Common; +using GetIntoTeachingApi.Jobs; +using Hangfire.States; +using System.Threading.Tasks; + namespace GetIntoTeachingApiTests.Controllers { public class OperationsControllerTests @@ -62,8 +63,8 @@ public void GenerateMappingInfo_RespondsWithMappingInfo() mappings.Any(m => m.LogicalName == "contact" && m.Class == "GetIntoTeachingApi.Models.Crm.Candidate" ).Should().BeTrue(); - } - + } + [Fact] public void PauseCrmIntegration_Authorize_IsPresent() { @@ -73,13 +74,13 @@ public void PauseCrmIntegration_Authorize_IsPresent() [Fact] public void PauseCrmIntegration_PausesFor6HoursAndRespondsWithNoContent() - { - var sixHoursFromNow = DateTime.UtcNow.AddHours(6); + { + var sixHoursFromNow = DateTime.UtcNow.AddHours(6); var response = _controller.PauseCrmIntegration(); - response.Should().BeOfType(); - + response.Should().BeOfType(); + _mockAppSettings.VerifySet(m => m.CrmIntegrationPausedUntil = It.Is(d => VerifyDateIsCloseTo(d, sixHoursFromNow)), Times.Once()); } @@ -96,11 +97,11 @@ public void ResumeCrmIntegration_ResumesAndRespondsWithNoContent() { var response = _controller.ResumeCrmIntegration(); - response.Should().BeOfType(); - + response.Should().BeOfType(); + _mockAppSettings.VerifySet(m => m.CrmIntegrationPausedUntil = null, Times.Once()); - } - + } + [Fact] public void BackfillApplyCandidates_Authorize_IsPresent() { @@ -109,47 +110,47 @@ public void BackfillApplyCandidates_Authorize_IsPresent() } [Fact] - public void BackfillApplyCandidates_WhenNotAlreadyRunning_EnqueuesJob() - { - var updatedSince = DateTime.MinValue; - _mockAppSettings.Setup(m => m.IsApplyBackfillInProgress).Returns(false); - + public void BackfillApplyCandidates_WhenNotAlreadyRunning_EnqueuesJob() + { + var updatedSince = DateTime.MinValue; + _mockAppSettings.Setup(m => m.IsApplyBackfillInProgress).Returns(false); + var response = _controller.BackfillApplyCandidates(updatedSince); - response.Should().BeOfType(); - - _mockJobClient.Verify(x => x.Create( - It.Is(job => job.Type == typeof(ApplyBackfillJob) && job.Method.Name == "RunAsync" && (DateTime)job.Args[0] == updatedSince), - It.IsAny()), Times.Once); + response.Should().BeOfType(); + + _mockJobClient.Verify(x => x.Create( + It.Is(job => job.Type == typeof(ApplyBackfillJob) && job.Method.Name == "RunAsync" && (DateTime)job.Args[0] == updatedSince), + It.IsAny()), Times.Once); } [Fact] - public void BackfillApplyCandidates_WhenAlreadyRunning_ReturnsBadRequest() - { - var updatedSince = DateTime.MinValue; - _mockAppSettings.Setup(m => m.IsApplyBackfillInProgress).Returns(true); - + public void BackfillApplyCandidates_WhenAlreadyRunning_ReturnsBadRequest() + { + var updatedSince = DateTime.MinValue; + _mockAppSettings.Setup(m => m.IsApplyBackfillInProgress).Returns(true); + var response = _controller.BackfillApplyCandidates(updatedSince); - response.Should().BeOfType(); - - _mockJobClient.Verify(x => x.Create( - It.Is(job => job.Type == typeof(ApplyBackfillJob) && job.Method.Name == "RunAsync" && (DateTime)job.Args[0] == updatedSince), - It.IsAny()),Times.Never); + response.Should().BeOfType(); + + _mockJobClient.Verify(x => x.Create( + It.Is(job => job.Type == typeof(ApplyBackfillJob) && job.Method.Name == "RunAsync" && (DateTime)job.Args[0] == updatedSince), + It.IsAny()),Times.Never); } [Theory] [InlineData(true, true, true, true, true, "healthy")] [InlineData(true, true, true, false, true, "degraded")] [InlineData(true, true, true, false, false, "degraded")] - [InlineData(true, true, true, true, false, "degraded")] + [InlineData(true, true, true, true, false, "degraded")] [InlineData(true, true, false, true, true, "degraded")] [InlineData(false, true, true, true, true, "unhealthy")] [InlineData(true, false, true, true, true, "unhealthy")] [InlineData(false, false, false, true, true, "unhealthy")] [InlineData(true, false, false, false, true, "unhealthy")] [InlineData(false, false, false, false, false, "unhealthy")] - public async void HealthCheck_ReturnsCorrectly(bool database, bool hangfire, bool redis, bool crm, bool notify, string expectedStatus) + public async Task HealthCheck_ReturnsCorrectly(bool database, bool hangfire, bool redis, bool crm, bool notify, string expectedStatus) { const string sha = "3c42c1051f6eb535c2017eafb660d1a884a39722"; const string environmentName = "Test"; @@ -181,13 +182,13 @@ public async void HealthCheck_ReturnsCorrectly(bool database, bool hangfire, boo health.Redis.Should().Be(redisStatus); health.Hangfire.Should().Be(hangfireStatus); health.Status.Should().Be(expectedStatus); - } - - private static bool VerifyDateIsCloseTo(DateTime date, DateTime closeToDate) - { - date.Should().BeCloseTo(closeToDate, TimeSpan.FromSeconds(30)); - - return true; + } + + private static bool VerifyDateIsCloseTo(DateTime date, DateTime closeToDate) + { + date.Should().BeCloseTo(closeToDate, TimeSpan.FromSeconds(30)); + + return true; } } } \ No newline at end of file diff --git a/GetIntoTeachingApiTests/Controllers/PickListItemsControllerTests.cs b/GetIntoTeachingApiTests/Controllers/PickListItemsControllerTests.cs index 280a16b7a..3fdc7e8fd 100644 --- a/GetIntoTeachingApiTests/Controllers/PickListItemsControllerTests.cs +++ b/GetIntoTeachingApiTests/Controllers/PickListItemsControllerTests.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Authorization; using Xunit; using GetIntoTeachingApi.Attributes; +using System.Threading.Tasks; namespace GetIntoTeachingApiTests.Controllers { @@ -35,7 +36,7 @@ public void PrivateShortTermResponseCache_IsPresent() } [Fact] - public async void GetCandidateInitialTeacherTrainingYears_ReturnsAllYears() + public async Task GetCandidateInitialTeacherTrainingYears_ReturnsAllYears() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_ittyear")).Returns(mockItems.AsAsyncQueryable()); @@ -47,7 +48,7 @@ public async void GetCandidateInitialTeacherTrainingYears_ReturnsAllYears() } [Fact] - public async void GetCandidatePreferredEducationPhases_ReturnsAllPhases() + public async Task GetCandidatePreferredEducationPhases_ReturnsAllPhases() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_preferrededucationphase01")) @@ -60,7 +61,7 @@ public async void GetCandidatePreferredEducationPhases_ReturnsAllPhases() } [Fact] - public async void GetCandidateChannels_ReturnsAllChannels() + public async Task GetCandidateChannels_ReturnsAllChannels() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_channelcreation")).Returns(mockItems.AsAsyncQueryable()); @@ -72,7 +73,7 @@ public async void GetCandidateChannels_ReturnsAllChannels() } [Fact] - public async void GetCandidateTeacherTrainingAdviserSubscriptionChannels_ReturnsAllChannels() + public async Task GetCandidateTeacherTrainingAdviserSubscriptionChannels_ReturnsAllChannels() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_gitisttaservicesubscriptionchannel")).Returns(mockItems.AsAsyncQueryable()); @@ -84,7 +85,7 @@ public async void GetCandidateTeacherTrainingAdviserSubscriptionChannels_Returns } [Fact] - public async void GetCandidateMailingListSubscriptionChannels_ReturnsAllChannels() + public async Task GetCandidateMailingListSubscriptionChannels_ReturnsAllChannels() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_gitismlservicesubscriptionchannel")).Returns(mockItems.AsAsyncQueryable()); @@ -96,7 +97,7 @@ public async void GetCandidateMailingListSubscriptionChannels_ReturnsAllChannels } [Fact] - public async void GetCandidateEventSubscriptionChannels_ReturnsAllChannels() + public async Task GetCandidateEventSubscriptionChannels_ReturnsAllChannels() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_gitiseventsservicesubscriptionchannel")).Returns(mockItems.AsAsyncQueryable()); @@ -108,7 +109,7 @@ public async void GetCandidateEventSubscriptionChannels_ReturnsAllChannels() } [Fact] - public async void GetCandidateGcseStatus_ReturnsAllStatus() + public async Task GetCandidateGcseStatus_ReturnsAllStatus() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_websitehasgcseenglish")).Returns(mockItems.AsAsyncQueryable()); @@ -120,7 +121,7 @@ public async void GetCandidateGcseStatus_ReturnsAllStatus() } [Fact] - public async void GetCandidateRetakeGcseStatus_ReturnsAllStatus() + public async Task GetCandidateRetakeGcseStatus_ReturnsAllStatus() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_websiteplanningretakeenglishgcse")).Returns(mockItems.AsAsyncQueryable()); @@ -132,7 +133,7 @@ public async void GetCandidateRetakeGcseStatus_ReturnsAllStatus() } [Fact] - public async void GetCandidateConsiderationJourneyStages_ReturnsAllStages() + public async Task GetCandidateConsiderationJourneyStages_ReturnsAllStages() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_websitewhereinconsiderationjourney")).Returns(mockItems.AsAsyncQueryable()); @@ -144,7 +145,7 @@ public async void GetCandidateConsiderationJourneyStages_ReturnsAllStages() } [Fact] - public async void GetCandidateTypes_ReturnsAllTypes() + public async Task GetCandidateTypes_ReturnsAllTypes() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_typeofcandidate")).Returns(mockItems.AsAsyncQueryable()); @@ -156,7 +157,7 @@ public async void GetCandidateTypes_ReturnsAllTypes() } [Fact] - public async void GetCandidateAssignmentStatus_ReturnsAllStatus() + public async Task GetCandidateAssignmentStatus_ReturnsAllStatus() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_candidatestatus")).Returns(mockItems.AsAsyncQueryable()); @@ -168,7 +169,7 @@ public async void GetCandidateAssignmentStatus_ReturnsAllStatus() } [Fact] - public async void GetCandidateAdviserEligibilities_ReturnsAllEligibilities() + public async Task GetCandidateAdviserEligibilities_ReturnsAllEligibilities() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_iscandidateeligibleforadviser")).Returns(mockItems.AsAsyncQueryable()); @@ -180,7 +181,7 @@ public async void GetCandidateAdviserEligibilities_ReturnsAllEligibilities() } [Fact] - public async void GetCandidateAdviserRequirements_ReturnsAllEligibilities() + public async Task GetCandidateAdviserRequirements_ReturnsAllEligibilities() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("contact", "dfe_isadvisorrequiredos")).Returns(mockItems.AsAsyncQueryable()); @@ -192,7 +193,7 @@ public async void GetCandidateAdviserRequirements_ReturnsAllEligibilities() } [Fact] - public async void GetQualificationDegreeStatus_ReturnsAllStatus() + public async Task GetQualificationDegreeStatus_ReturnsAllStatus() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("dfe_candidatequalification", "dfe_degreestatus")).Returns(mockItems.AsAsyncQueryable()); @@ -204,7 +205,7 @@ public async void GetQualificationDegreeStatus_ReturnsAllStatus() } [Fact] - public async void GetQualificationTypes_ReturnsAllTypes() + public async Task GetQualificationTypes_ReturnsAllTypes() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("dfe_candidatequalification", "dfe_type")).Returns(mockItems.AsAsyncQueryable()); @@ -216,7 +217,7 @@ public async void GetQualificationTypes_ReturnsAllTypes() } [Fact] - public async void GetQualificationUkDegreeGrades_ReturnsAllGrades() + public async Task GetQualificationUkDegreeGrades_ReturnsAllGrades() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("dfe_candidatequalification", "dfe_ukdegreegrade")).Returns(mockItems.AsAsyncQueryable()); @@ -228,7 +229,7 @@ public async void GetQualificationUkDegreeGrades_ReturnsAllGrades() } [Fact] - public async void GetPastTeachingPositionEducationPhases_ReturnsAllPhases() + public async Task GetPastTeachingPositionEducationPhases_ReturnsAllPhases() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("dfe_candidatepastteachingposition", "dfe_educationphase")) @@ -241,7 +242,7 @@ public async void GetPastTeachingPositionEducationPhases_ReturnsAllPhases() } [Fact] - public async void GetTeachingEventTypes_ReturnsAllTypes() + public async Task GetTeachingEventTypes_ReturnsAllTypes() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("msevtmgt_event", "dfe_event_type")).Returns(mockItems.AsAsyncQueryable()); @@ -253,7 +254,7 @@ public async void GetTeachingEventTypes_ReturnsAllTypes() } [Fact] - public async void GetTeachingEventRegions_ReturnsAllRegions() + public async Task GetTeachingEventRegions_ReturnsAllRegions() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("msevtmgt_event", "dfe_eventregion")).Returns(mockItems.AsAsyncQueryable()); @@ -265,7 +266,7 @@ public async void GetTeachingEventRegions_ReturnsAllRegions() } [Fact] - public async void GetTeachingEventStatus_ReturnsAllStatus() + public async Task GetTeachingEventStatus_ReturnsAllStatus() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("msevtmgt_event", "dfe_eventstatus")).Returns(mockItems.AsAsyncQueryable()); @@ -277,7 +278,7 @@ public async void GetTeachingEventStatus_ReturnsAllStatus() } [Fact] - public async void GetTeachingEventRegistrationChannels_ReturnsAllChannels() + public async Task GetTeachingEventRegistrationChannels_ReturnsAllChannels() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("msevtmgt_eventregistration", "dfe_channelcreation")).Returns(mockItems.AsAsyncQueryable()); @@ -289,7 +290,7 @@ public async void GetTeachingEventRegistrationChannels_ReturnsAllChannels() } [Fact] - public async void GetPhoneCallChannels_ReturnsAllChannels() + public async Task GetPhoneCallChannels_ReturnsAllChannels() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("phonecall", "dfe_channelcreation")).Returns(mockItems.AsAsyncQueryable()); @@ -301,7 +302,7 @@ public async void GetPhoneCallChannels_ReturnsAllChannels() } [Fact] - public async void GetSubscriptionTypes_ReturnsAllTypes() + public async Task GetSubscriptionTypes_ReturnsAllTypes() { var mockItems = MockPickListItems(); _mockStore.Setup(mock => mock.GetPickListItems("dfe_servicesubscription", "dfe_servicesubscriptiontype")) diff --git a/GetIntoTeachingApiTests/Controllers/PrivacyPoliciesControllerTests.cs b/GetIntoTeachingApiTests/Controllers/PrivacyPoliciesControllerTests.cs index c86b53921..f1d16cf78 100644 --- a/GetIntoTeachingApiTests/Controllers/PrivacyPoliciesControllerTests.cs +++ b/GetIntoTeachingApiTests/Controllers/PrivacyPoliciesControllerTests.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Moq; using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Xunit; using GetIntoTeachingApi.Attributes; @@ -26,8 +27,8 @@ public PrivacyPoliciesControllerTests() public void Authorize_IsPresent() { typeof(PrivacyPoliciesController).Should().BeDecoratedWith(); - } - + } + [Fact] public void PrivateShortTermResponseCache_IsPresent() { @@ -35,7 +36,7 @@ public void PrivateShortTermResponseCache_IsPresent() } [Fact] - public async void Get_ReturnsPrivacyPolicy() + public async Task Get_ReturnsPrivacyPolicy() { var policy = new PrivacyPolicy() { Id = Guid.NewGuid() }; _mockStore.Setup(mock => mock.GetPrivacyPolicyAsync((Guid)policy.Id)).ReturnsAsync(policy); @@ -47,7 +48,7 @@ public async void Get_ReturnsPrivacyPolicy() } [Fact] - public async void Get_WithMissingEvent_ReturnsNotFound() + public async Task Get_WithMissingEvent_ReturnsNotFound() { _mockStore.Setup(mock => mock.GetTeachingEventAsync(It.IsAny())).ReturnsAsync(null as TeachingEvent); @@ -57,7 +58,7 @@ public async void Get_WithMissingEvent_ReturnsNotFound() } [Fact] - public async void GetLatest_ReturnsLatestPrivacyPolicy() + public async Task GetLatest_ReturnsLatestPrivacyPolicy() { var mockPolicy = MockPrivacyPolicy(); _mockStore.Setup(mock => mock.GetLatestPrivacyPolicyAsync()).ReturnsAsync(mockPolicy); diff --git a/GetIntoTeachingApiTests/Jobs/ApplyBackfillJobTests.cs b/GetIntoTeachingApiTests/Jobs/ApplyBackfillJobTests.cs index c5478b224..4f47be0d1 100644 --- a/GetIntoTeachingApiTests/Jobs/ApplyBackfillJobTests.cs +++ b/GetIntoTeachingApiTests/Jobs/ApplyBackfillJobTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using FluentAssertions; using Flurl.Http.Testing; using GetIntoTeachingApi.Jobs; @@ -54,7 +55,7 @@ public void DisableConcurrentExecutionAttribute() } [Fact] - public async void RunAsync_WhenMultiplePagesAvailable_QueuesCandidateJobsForEachPageAndRequeuesBackfillJobOnEndPage() + public async Task RunAsync_WhenMultiplePagesAvailable_QueuesCandidateJobsForEachPageAndRequeuesBackfillJobOnEndPage() { var updatedSince = DateTime.MinValue; @@ -87,7 +88,7 @@ public async void RunAsync_WhenMultiplePagesAvailable_QueuesCandidateJobsForEach } [Fact] - public async void RunAsync_WithNoCandidates_DoesNotQueueJobs() + public async Task RunAsync_WithNoCandidates_DoesNotQueueJobs() { var updatedSince = DateTime.MinValue; using (var httpTest = new HttpTest()) diff --git a/GetIntoTeachingApiTests/Jobs/ApplySyncJobTests.cs b/GetIntoTeachingApiTests/Jobs/ApplySyncJobTests.cs index d33138c9e..9b99198b7 100644 --- a/GetIntoTeachingApiTests/Jobs/ApplySyncJobTests.cs +++ b/GetIntoTeachingApiTests/Jobs/ApplySyncJobTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Linq; using FluentAssertions; using Flurl.Http.Testing; @@ -59,7 +60,7 @@ public void DisableConcurrentExecutionAttribute() } [Fact] - public async void RunAsync_WithUpdatedCandidates_QueuesCandidateJobs() + public async Task RunAsync_WithUpdatedCandidates_QueuesCandidateJobs() { var metricCount = _metrics.ApplySyncDuration.Count; var lastSyncAt = new DateTime(2020, 1, 1); @@ -88,7 +89,7 @@ public async void RunAsync_WithUpdatedCandidates_QueuesCandidateJobs() } [Fact] - public async void RunAsync_WhenMultiplePagesAvailable_QueuesCandidateJobsForEachPage() + public async Task RunAsync_WhenMultiplePagesAvailable_QueuesCandidateJobsForEachPage() { var lastSyncAt = new DateTime(2020, 1, 1); _mockAppSettings.Setup(m => m.ApplyLastSyncAt).Returns(lastSyncAt); @@ -114,7 +115,7 @@ public async void RunAsync_WhenMultiplePagesAvailable_QueuesCandidateJobsForEach } [Fact] - public async void RunAsync_WithNoUpdatedCandidates_DoesNotQueueJobs() + public async Task RunAsync_WithNoUpdatedCandidates_DoesNotQueueJobs() { var metricCount = _metrics.ApplySyncDuration.Count; var lastSyncAt = new DateTime(2020, 1, 1); @@ -138,7 +139,7 @@ public async void RunAsync_WithNoUpdatedCandidates_DoesNotQueueJobs() } [Fact] - public async void RunAsync_OnFirstRun_GetsUpdatedSinceNow() + public async Task RunAsync_OnFirstRun_GetsUpdatedSinceNow() { var now = DateTime.UtcNow; _mockDateTime.Setup(m => m.UtcNow).Returns(now); @@ -157,7 +158,7 @@ public async void RunAsync_OnFirstRun_GetsUpdatedSinceNow() } [Fact] - public async void RunAsync_OnSuccess_UpdatesLastSyncAt() + public async Task RunAsync_OnSuccess_UpdatesLastSyncAt() { var lastSyncAt = DateTime.UtcNow.AddMonths(-1); _mockAppSettings.Setup(m => m.ApplyLastSyncAt).Returns(lastSyncAt); diff --git a/GetIntoTeachingApiTests/Jobs/CrmSyncJobTests.cs b/GetIntoTeachingApiTests/Jobs/CrmSyncJobTests.cs index 9635854b3..da5f5ed4e 100644 --- a/GetIntoTeachingApiTests/Jobs/CrmSyncJobTests.cs +++ b/GetIntoTeachingApiTests/Jobs/CrmSyncJobTests.cs @@ -1,6 +1,6 @@ using FluentAssertions; using GetIntoTeachingApi.Jobs; -using GetIntoTeachingApi.Models; +using GetIntoTeachingApi.Models; using GetIntoTeachingApi.Services; using GetIntoTeachingApi.Utils; using GetIntoTeachingApiTests.Helpers; @@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging; using Moq; using Xunit; +using System.Threading.Tasks; namespace GetIntoTeachingApiTests.Jobs { @@ -37,7 +38,7 @@ public void DisableConcurrentExecutionAttribute() } [Fact] - public async void RunAsync_CallsSync() + public async Task RunAsync_CallsSync() { _mockAppSettings.Setup(m => m.IsCrmIntegrationPaused).Returns(false); @@ -50,7 +51,7 @@ public async void RunAsync_CallsSync() } [Fact] - public async void RunAsync_WhenCrmIntegrationPaused_DoesNotCallSync() + public async Task RunAsync_WhenCrmIntegrationPaused_DoesNotCallSync() { _mockAppSettings.Setup(m => m.IsCrmIntegrationPaused).Returns(true); diff --git a/GetIntoTeachingApiTests/Jobs/LocationSyncJobTests.cs b/GetIntoTeachingApiTests/Jobs/LocationSyncJobTests.cs index 28b31a9f1..f6184c698 100644 --- a/GetIntoTeachingApiTests/Jobs/LocationSyncJobTests.cs +++ b/GetIntoTeachingApiTests/Jobs/LocationSyncJobTests.cs @@ -1,20 +1,21 @@ using System.Collections.Generic; -using System.Linq; +using System.Linq; +using System.Threading.Tasks; using FluentAssertions; -using GetIntoTeachingApi.Database; +using GetIntoTeachingApi.Database; using GetIntoTeachingApi.Jobs; using GetIntoTeachingApi.Services; using GetIntoTeachingApi.Utils; using GetIntoTeachingApiTests.Helpers; using Microsoft.Extensions.Logging; using Moq; -using NetTopologySuite; -using NetTopologySuite.Geometries; +using NetTopologySuite; +using NetTopologySuite.Geometries; using WireMock.RequestBuilders; using WireMock.ResponseBuilders; using WireMock.Server; -using Xunit; - +using Xunit; + namespace GetIntoTeachingApiTests.Jobs { [Collection("Database")] @@ -35,13 +36,13 @@ public LocationSyncJobTests(DatabaseFixture databaseFixture) : base(databaseFixt } [Fact] - public void FreeMapToolsUrl_IsCorrect() - { - LocationSyncJob.FreeMapToolsUrl.Should().Be("https://data.freemaptools.com/download/full-uk-postcodes/ukpostcodes.zip"); + public void FreeMapToolsUrl_IsCorrect() + { + LocationSyncJob.FreeMapToolsUrl.Should().Be("https://data.freemaptools.com/download/full-uk-postcodes/ukpostcodes.zip"); } [Fact] - public async void RunAsync_UpsertsLocations() + public async Task RunAsync_UpsertsLocations() { _mockEnv.Setup(m => m.IsDevelopment).Returns(false); var server = WireMockServer.Start(); @@ -72,10 +73,10 @@ public async void RunAsync_UpsertsLocations() _mockLogger.VerifyInformationWasCalled("LocationSyncJob - Succeeded"); _metrics.LocationSyncDuration.Count.Should().BeGreaterOrEqualTo(1); - } - + } + [Fact] - public async void RunAsync_WhenCsvOmitsHeaderRow_UpsertsLocations() + public async Task RunAsync_WhenCsvOmitsHeaderRow_UpsertsLocations() { _mockEnv.Setup(m => m.IsDevelopment).Returns(false); var server = WireMockServer.Start(); @@ -96,10 +97,10 @@ public async void RunAsync_WhenCsvOmitsHeaderRow_UpsertsLocations() DbContext.Locations.ToList().All(existingLocation => csvLocations.Any(csvLocation => MatchCsvLocationWithExisting(csvLocation, existingLocation))).Should().BeTrue(); DbContext.Locations.All(l => l.Source == GetIntoTeachingApi.Models.Location.SourceType.CSV); - } - + } + [Fact] - public async void RunAsync_WhenCsvContainsMalformedRows_SkipsMalformedRows() + public async Task RunAsync_WhenCsvContainsMalformedRows_SkipsMalformedRows() { _mockEnv.Setup(m => m.IsDevelopment).Returns(false); var server = WireMockServer.Start(); @@ -120,10 +121,10 @@ public async void RunAsync_WhenCsvContainsMalformedRows_SkipsMalformedRows() DbContext.Locations.ToList().All(existingLocation => csvLocations.Any(csvLocation => MatchCsvLocationWithExisting(csvLocation, existingLocation))).Should().BeTrue(); DbContext.Locations.All(l => l.Source == GetIntoTeachingApi.Models.Location.SourceType.CSV); - } - - private static IEnumerable CsvLocations() - { + } + + private static IEnumerable CsvLocations() + { return new List { new { Postcode = "ky119yu", Latitude = 56.02748, Longitude = -3.35870 }, @@ -131,9 +132,9 @@ private static IEnumerable CsvLocations() new { Postcode = "ky62nj", Latitude = 56.182790, Longitude = -3.178240 }, new { Postcode = "kw14yl", Latitude = 58.64102, Longitude = -3.10075 }, new { Postcode = "tr182ab", Latitude = 50.12279, Longitude = -5.53987 }, - }; - } - + }; + } + private static bool MatchCsvLocationWithExisting(dynamic csvLocation, GetIntoTeachingApi.Models.Location existingLocation) { var postcodeMatch = csvLocation.Postcode == existingLocation.Postcode; diff --git a/GetIntoTeachingApiTests/Middleware/RequestResponseLoggingMiddlewareTests.cs b/GetIntoTeachingApiTests/Middleware/RequestResponseLoggingMiddlewareTests.cs index 5447aae0c..bd3af992c 100644 --- a/GetIntoTeachingApiTests/Middleware/RequestResponseLoggingMiddlewareTests.cs +++ b/GetIntoTeachingApiTests/Middleware/RequestResponseLoggingMiddlewareTests.cs @@ -1,10 +1,10 @@ -using System; -using System.IO; +using System; +using System.IO; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Threading.Tasks; -using GetIntoTeachingApi.Middleware; +using GetIntoTeachingApi.Middleware; using GetIntoTeachingApiTests.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -34,7 +34,7 @@ public RequestResponseLoggingMiddlewareTests() } [Fact] - public async void Invoke_WithJsonPayloadAndCompactLoggingPath_LogsRequestAndResponseWithoutPayload() + public async Task Invoke_WithJsonPayloadAndCompactLoggingPath_LogsRequestAndResponseWithoutPayload() { var regex = new Regex(@"^GET /path", RegexOptions.Compiled | RegexOptions.IgnoreCase); _mockConfig.Setup(m => m.CompactLoggingPatterns).Returns(new Regex[] { regex }); @@ -61,7 +61,7 @@ public async void Invoke_WithJsonPayloadAndCompactLoggingPath_LogsRequestAndResp } [Fact] - public async void Invoke_WithJsonPayload_LogsRequestAndResponseWithRedactedPayloads() + public async Task Invoke_WithJsonPayload_LogsRequestAndResponseWithRedactedPayloads() { string json = JsonSerializer.Serialize(new { @@ -94,7 +94,7 @@ public async void Invoke_WithJsonPayload_LogsRequestAndResponseWithRedactedPaylo } [Fact] - public async void Invoke_WithNonJsonPayload_LogsRequestAndResponseWithEmptyPayloads() + public async Task Invoke_WithNonJsonPayload_LogsRequestAndResponseWithEmptyPayloads() { var text = "my password is 123456"; diff --git a/GetIntoTeachingApiTests/Services/NotifyServiceTests.cs b/GetIntoTeachingApiTests/Services/NotifyServiceTests.cs index e238fe554..7bf54296c 100644 --- a/GetIntoTeachingApiTests/Services/NotifyServiceTests.cs +++ b/GetIntoTeachingApiTests/Services/NotifyServiceTests.cs @@ -31,7 +31,7 @@ public NotifyServiceTests() } [Fact] - public async void CheckStatusAsync_WhenHealthy_ReturnsOk() + public async Task CheckStatusAsync_WhenHealthy_ReturnsOk() { _mockNotificationClient.Setup(mock => mock.CheckStatusAsync("api_key")).ReturnsAsync(HealthCheckResponse.StatusOk); @@ -39,7 +39,7 @@ public async void CheckStatusAsync_WhenHealthy_ReturnsOk() } [Fact] - public async void CheckStatusAsync_WhenUnhealthy_ReturnsError() + public async Task CheckStatusAsync_WhenUnhealthy_ReturnsError() { _mockNotificationClient.Setup(mock => mock.CheckStatusAsync("api_key")).ReturnsAsync("some error"); diff --git a/GetIntoTeachingApiTests/Services/PaginatorClientTests.cs b/GetIntoTeachingApiTests/Services/PaginatorClientTests.cs index 7a47a6d61..b8a0a120c 100644 --- a/GetIntoTeachingApiTests/Services/PaginatorClientTests.cs +++ b/GetIntoTeachingApiTests/Services/PaginatorClientTests.cs @@ -1,11 +1,12 @@ -using System.Collections.Generic; -using FluentAssertions; -using Flurl; +using System.Collections.Generic; +using FluentAssertions; +using Flurl; using Flurl.Http; using Flurl.Http.Testing; -using GetIntoTeachingApi.Services; +using GetIntoTeachingApi.Services; using Newtonsoft.Json; using Xunit; +using System.Threading.Tasks; namespace GetIntoTeachingApiTests.Services { @@ -25,7 +26,7 @@ public PaginatorClientTests() [Fact] - public async void Constructot_WithCustomStartPage() + public async Task Constructot_WithCustomStartPage() { var paginator = new PaginatorClient(_request, 2); using var httpTest = new HttpTest(); @@ -40,7 +41,7 @@ public async void Constructot_WithCustomStartPage() } [Fact] - public async void Page_Increments() + public async Task Page_Increments() { using var httpTest = new HttpTest(); MockResponse(httpTest, "page 1 data", 1, 2); @@ -64,7 +65,7 @@ public void HasNext_BeforeRetrievingFirstPage_IsTrue() } [Fact] - public async void HasNext_WhenThereAreMorePages_IsTrue() + public async Task HasNext_WhenThereAreMorePages_IsTrue() { using var httpTest = new HttpTest(); MockResponse(httpTest, "page 1 data", 1, 2); @@ -76,7 +77,7 @@ public async void HasNext_WhenThereAreMorePages_IsTrue() } [Fact] - public async void HasNext_WhenThereAreNoMorePages_IsFalse() + public async Task HasNext_WhenThereAreNoMorePages_IsFalse() { using var httpTest = new HttpTest(); MockResponse(httpTest, "page 1 data", 1, 2); @@ -89,7 +90,7 @@ public async void HasNext_WhenThereAreNoMorePages_IsFalse() } [Fact] - public async void NextAsync_FirstCall_RetrievesPage1() + public async Task NextAsync_FirstCall_RetrievesPage1() { using var httpTest = new HttpTest(); MockResponse(httpTest, "page 1 data"); @@ -100,7 +101,7 @@ public async void NextAsync_FirstCall_RetrievesPage1() } [Fact] - public async void NextAsync_SecondCall_RetrievesPage2() + public async Task NextAsync_SecondCall_RetrievesPage2() { using var httpTest = new HttpTest(); MockResponse(httpTest, "page 1 data", 1, 2); diff --git a/GetIntoTeachingApiTests/Services/StoreTests.cs b/GetIntoTeachingApiTests/Services/StoreTests.cs index ffcdc4be4..bb3e15c9e 100644 --- a/GetIntoTeachingApiTests/Services/StoreTests.cs +++ b/GetIntoTeachingApiTests/Services/StoreTests.cs @@ -9,7 +9,7 @@ using GetIntoTeachingApi.Models.Crm; using GetIntoTeachingApi.Models.GetIntoTeaching; using GetIntoTeachingApi.Services; -using GetIntoTeachingApi.Utils; +using GetIntoTeachingApi.Utils; using GetIntoTeachingApiTests.Helpers; using Microsoft.EntityFrameworkCore; using Moq; @@ -40,20 +40,20 @@ public StoreTests(DatabaseFixture databaseFixture) : base(databaseFixture) } [Fact] - public async void CheckStatusAsync_WhenHealthy_ReturnsOk() + public async Task CheckStatusAsync_WhenHealthy_ReturnsOk() { (await _store.CheckStatusAsync()).Should().Be(HealthCheckResponse.StatusOk); } [Fact] - public async void CheckStatusAsync_WhenUnhealthy_ReturnsError() + public async Task CheckStatusAsync_WhenUnhealthy_ReturnsError() { await DbContext.DisposeAsync(); (await _store.CheckStatusAsync()).Should().Contain("Cannot access a disposed context instance."); } [Fact] - public async void SyncAsync_WithFailure_RetainsExistingData() + public async Task SyncAsync_WithFailure_RetainsExistingData() { await SeedMockPrivacyPoliciesAsync(); var countBefore = DbContext.PrivacyPolicies.Count(); @@ -67,7 +67,7 @@ public async void SyncAsync_WithFailure_RetainsExistingData() } [Fact] - public async void SyncAsync_InsertsNewTeachingEvents() + public async Task SyncAsync_InsertsNewTeachingEvents() { await SeedMockTeachingEventBuildingsAsync(); var mockTeachingEvents = MockTeachingEvents().ToList(); @@ -81,14 +81,14 @@ public async void SyncAsync_InsertsNewTeachingEvents() } [Fact] - public async void SyncAsync_UpdatesExistingTeachingEvents() + public async Task SyncAsync_UpdatesExistingTeachingEvents() { var updatedTeachingEvents = (await SeedMockTeachingEventsAndBuildingsAsync()).ToList(); updatedTeachingEvents.ForEach(te => { te.Name += "Updated"; if (te.Building != null) te.Building.AddressLine1 += "Updated"; - }); + }); _mockCrm.Setup(m => m.GetTeachingEvents(It.Is(d => CheckGetTeachingEventsAfterDate(d)))).Returns(updatedTeachingEvents); await _store.SyncAsync(); @@ -102,7 +102,7 @@ public async void SyncAsync_UpdatesExistingTeachingEvents() } [Fact] - public async void SyncAsync_DeletesOrphanedTeachingEvents() + public async Task SyncAsync_DeletesOrphanedTeachingEvents() { await SeedMockTeachingEventsAndBuildingsAsync(); var teachingEvent = MockTeachingEvents().ToList().GetRange(0, 1); @@ -117,7 +117,7 @@ public async void SyncAsync_DeletesOrphanedTeachingEvents() } [Fact] - public async void SyncAsync_InsertsNewTeachingEventBuildings() + public async Task SyncAsync_InsertsNewTeachingEventBuildings() { var mockTeachingEventBuildings = MockTeachingEventBuildings(); _mockCrm.Setup(m => m.GetTeachingEventBuildings()).Returns(mockTeachingEventBuildings); @@ -130,13 +130,13 @@ public async void SyncAsync_InsertsNewTeachingEventBuildings() } [Fact] - public async void SyncAsync_UpdatesExistingTeachingEventBuildings() + public async Task SyncAsync_UpdatesExistingTeachingEventBuildings() { var updatedTeachingEventBuildings = (await SeedMockTeachingEventBuildingsAsync()).ToList(); updatedTeachingEventBuildings.ForEach(building => { building.AddressLine1 += "Updated"; - }); + }); _mockCrm.Setup(m => m.GetTeachingEventBuildings()).Returns(updatedTeachingEventBuildings); await _store.SyncAsync(); @@ -147,7 +147,7 @@ public async void SyncAsync_UpdatesExistingTeachingEventBuildings() } [Fact] - public async void SyncAsync_DeletesOrphanedTeachingEventBuildings() + public async Task SyncAsync_DeletesOrphanedTeachingEventBuildings() { var buildings = await SeedMockTeachingEventBuildingsAsync(); var building = buildings.ToList().GetRange(0, 1); @@ -160,11 +160,11 @@ public async void SyncAsync_DeletesOrphanedTeachingEventBuildings() } [Fact] - public async void SyncAsync_PopulatesTeachingEventBuildingCoordinates() + public async Task SyncAsync_PopulatesTeachingEventBuildingCoordinates() { await SeedMockTeachingEventBuildingsAsync(); - SeedMockLocations(); - + SeedMockLocations(); + Store.ClearFailedPostcodeLookupCache(); _mockCrm.Setup(m => m.GetTeachingEvents(It.Is(d => CheckGetTeachingEventsAfterDate(d)))).Returns(MockTeachingEvents); @@ -176,11 +176,11 @@ public async void SyncAsync_PopulatesTeachingEventBuildingCoordinates() } [Fact] - public async void SyncAsync_FallbackToGeocodeClient_PopulatesTeachingEventBuildingCoordinatesAndCachesLocation() + public async Task SyncAsync_FallbackToGeocodeClient_PopulatesTeachingEventBuildingCoordinatesAndCachesLocation() { await SeedMockTeachingEventBuildingsAsync(); - SeedMockLocations(); - + SeedMockLocations(); + Store.ClearFailedPostcodeLookupCache(); _mockCrm.Setup(m => m.GetTeachingEvents(It.Is(d => CheckGetTeachingEventsAfterDate(d)))).Returns(MockTeachingEvents); @@ -201,7 +201,7 @@ public async void SyncAsync_FallbackToGeocodeClient_PopulatesTeachingEventBuildi } [Fact] - public async void SyncAsync_InsertsNewPrivacyPolicies() + public async Task SyncAsync_InsertsNewPrivacyPolicies() { var mockPolicies = MockPrivacyPolicies().ToList(); _mockCrm.Setup(m => m.GetPrivacyPolicies()).Returns(mockPolicies); @@ -214,7 +214,7 @@ public async void SyncAsync_InsertsNewPrivacyPolicies() } [Fact] - public async void SyncAsync_UpdatesExistingPrivacyPolicies() + public async Task SyncAsync_UpdatesExistingPrivacyPolicies() { var updatedPolicies = (await SeedMockPrivacyPoliciesAsync()).ToList(); updatedPolicies.ForEach(te => te.Text += "Updated"); @@ -228,7 +228,7 @@ public async void SyncAsync_UpdatesExistingPrivacyPolicies() } [Fact] - public async void SyncAsync_DeletesOrphanedPrivacyPolicies() + public async Task SyncAsync_DeletesOrphanedPrivacyPolicies() { var policies = (await SeedMockPrivacyPoliciesAsync()).ToList(); _mockCrm.Setup(m => m.GetPrivacyPolicies()).Returns(policies.GetRange(0, 2)); @@ -240,7 +240,7 @@ public async void SyncAsync_DeletesOrphanedPrivacyPolicies() } [Fact] - public async void SyncAsync_InsertsNewLookupItems() + public async Task SyncAsync_InsertsNewLookupItems() { var mockCountries = MockCountries(); _mockCrm.Setup(m => m.GetCountries()).Returns(mockCountries); @@ -253,7 +253,7 @@ public async void SyncAsync_InsertsNewLookupItems() } [Fact] - public async void SyncAsync_UpdatesExistingLookupItems() + public async Task SyncAsync_UpdatesExistingLookupItems() { var updatedCountries = (await SeedMockCountriesAsync()).ToList(); updatedCountries.ForEach(c => c.Value += "Updated"); @@ -267,7 +267,7 @@ public async void SyncAsync_UpdatesExistingLookupItems() } [Fact] - public async void SyncAsync_DeletesOrphanedLookupItems() + public async Task SyncAsync_DeletesOrphanedLookupItems() { var countries = (await SeedMockCountriesAsync()).ToList(); _mockCrm.Setup(m => m.GetCountries()).Returns((IEnumerable)countries.GetRange(0, 2)); @@ -279,7 +279,7 @@ public async void SyncAsync_DeletesOrphanedLookupItems() } [Fact] - public async void SyncAsync_InsertsNewPickListItems() + public async Task SyncAsync_InsertsNewPickListItems() { var mockYears = MockInitialTeacherTrainingYears().ToList(); _mockCrm.Setup(m => m.GetPickListItems("contact", "dfe_ittyear")).Returns(mockYears); @@ -292,7 +292,7 @@ public async void SyncAsync_InsertsNewPickListItems() } [Fact] - public async void SyncAsync_UpdatesExistingPickListItems() + public async Task SyncAsync_UpdatesExistingPickListItems() { var updatedYears = (await SeedMockInitialTeacherTrainingYearsAsync()).ToList(); updatedYears.ForEach(c => c.Value += "Updated"); @@ -303,35 +303,35 @@ public async void SyncAsync_UpdatesExistingPickListItems() var countries = DbContext.PickListItems.ToList(); countries.Select(c => c.Value).ToList().ForEach(value => value.Should().Contain("Updated")); DbContext.PickListItems.Count().Should().Be(3); - } - + } + [Fact] - public async void SyncAsync_InsertsApplyPickListItems() + public async Task SyncAsync_InsertsApplyPickListItems() { _mockCrm.Setup(m => m.GetPickListItems("contact", "dfe_candidateapplystatus")).Returns(Array.Empty()).Verifiable(); _mockCrm.Setup(m => m.GetPickListItems("contact", "dfe_candidateapplyphase")).Returns(Array.Empty()).Verifiable(); _mockCrm.Setup(m => m.GetPickListItems("dfe_applyapplicationform", "dfe_applyphase")).Returns(Array.Empty()).Verifiable(); - _mockCrm.Setup(m => m.GetPickListItems("dfe_applyapplicationform", "dfe_applystatus")).Returns(Array.Empty()).Verifiable(); - _mockCrm.Setup(m => m.GetPickListItems("dfe_applyapplicationchoice", "dfe_applicationchoicestatus")).Returns(Array.Empty()).Verifiable(); + _mockCrm.Setup(m => m.GetPickListItems("dfe_applyapplicationform", "dfe_applystatus")).Returns(Array.Empty()).Verifiable(); + _mockCrm.Setup(m => m.GetPickListItems("dfe_applyapplicationchoice", "dfe_applicationchoicestatus")).Returns(Array.Empty()).Verifiable(); _mockCrm.Setup(m => m.GetPickListItems("dfe_applyreference", "dfe_referencefeedbackstatus")).Returns(Array.Empty()).Verifiable(); await _store.SyncAsync(); _mockCrm.Verify(); } - - [Fact] - public async void SyncAsync_InsertsRegionIdPickListItem() - { - _mockCrm.Setup(m => m.GetPickListItems("msevtmgt_event", "dfe_eventregion")).Returns(Array.Empty()).Verifiable(); - - await _store.SyncAsync(); - - _mockCrm.Verify(); + + [Fact] + public async Task SyncAsync_InsertsRegionIdPickListItem() + { + _mockCrm.Setup(m => m.GetPickListItems("msevtmgt_event", "dfe_eventregion")).Returns(Array.Empty()).Verifiable(); + + await _store.SyncAsync(); + + _mockCrm.Verify(); } [Fact] - public async void SyncAsync_DeletesOrphanedPickListItems() + public async Task SyncAsync_DeletesOrphanedPickListItems() { var years = (await SeedMockInitialTeacherTrainingYearsAsync()).ToList(); _mockCrm.Setup(m => m.GetPickListItems("contact", "dfe_ittyear")).Returns(years.GetRange(0, 2)); @@ -344,17 +344,17 @@ public async void SyncAsync_DeletesOrphanedPickListItems() } [Fact] - public async void GetLookupItems_ReturnsMatchingOrderedByIdAscending() + public async Task GetLookupItems_ReturnsMatchingOrderedByIdAscending() { await SeedMockCountriesAsync(); var result = _store.GetCountries(); result.Select(t => t.Value).Should().BeEquivalentTo(new string[] { "Country 1", "Country 2", "Country 3" }); - } - + } + [Fact] - public async void GetPickListItems_ReturnsMatchingOrderedByIdAscending() + public async Task GetPickListItems_ReturnsMatchingOrderedByIdAscending() { await SeedMockInitialTeacherTrainingYearsAsync(); @@ -364,7 +364,7 @@ public async void GetPickListItems_ReturnsMatchingOrderedByIdAscending() } [Fact] - public async void GetPrivacyPolicies_ReturnsAll() + public async Task GetPrivacyPolicies_ReturnsAll() { await SeedMockPrivacyPoliciesAsync(); @@ -374,7 +374,7 @@ public async void GetPrivacyPolicies_ReturnsAll() } [Fact] - public async void GetLatestPrivacyPolicy_ReturnsMostRecent() + public async Task GetLatestPrivacyPolicy_ReturnsMostRecent() { await SeedMockPrivacyPoliciesAsync(); @@ -384,7 +384,7 @@ public async void GetLatestPrivacyPolicy_ReturnsMostRecent() } [Fact] - public async void GetPrivacyPolicy_ReturnsMatchingPolicy() + public async Task GetPrivacyPolicy_ReturnsMatchingPolicy() { var policies = await SeedMockPrivacyPoliciesAsync(); var result = await _store.GetPrivacyPolicyAsync((Guid)policies.First().Id); @@ -393,7 +393,7 @@ public async void GetPrivacyPolicy_ReturnsMatchingPolicy() } [Fact] - public async void SearchTeachingEvents_WithoutFilters_ReturnsAll() + public async Task SearchTeachingEvents_WithoutFilters_ReturnsAll() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() { }; @@ -406,21 +406,21 @@ public async void SearchTeachingEvents_WithoutFilters_ReturnsAll() } [Fact] - public async void SearchTeachingEventsAsync_WithInvalidPostcode_IsCached() - { - var request = new TeachingEventSearchRequest() { Postcode = "TE7 1NG", Radius = 100 }; + public async Task SearchTeachingEventsAsync_WithInvalidPostcode_IsCached() + { + var request = new TeachingEventSearchRequest() { Postcode = "TE7 1NG", Radius = 100 }; var sanitizedPostcode = Location.SanitizePostcode(request.Postcode); - - _mockGeocodeClient.Setup(m => m.GeocodePostcodeAsync(sanitizedPostcode)).ReturnsAsync(null as Point); - - await _store.SearchTeachingEventsAsync(request); - await _store.SearchTeachingEventsAsync(request); - - _mockGeocodeClient.Verify(m => m.GeocodePostcodeAsync(sanitizedPostcode), Times.Once); + + _mockGeocodeClient.Setup(m => m.GeocodePostcodeAsync(sanitizedPostcode)).ReturnsAsync(null as Point); + + await _store.SearchTeachingEventsAsync(request); + await _store.SearchTeachingEventsAsync(request); + + _mockGeocodeClient.Verify(m => m.GeocodePostcodeAsync(sanitizedPostcode), Times.Once); } [Fact] - public async void SearchTeachingEvents_WithFilters_ReturnsMatching() + public async Task SearchTeachingEvents_WithFilters_ReturnsMatching() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -442,7 +442,7 @@ public async void SearchTeachingEvents_WithFilters_ReturnsMatching() } [Fact] - public async void SearchTeachingEvents_WithFilters_ReturnsEventNarrowlyInRange() + public async Task SearchTeachingEvents_WithFilters_ReturnsEventNarrowlyInRange() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -463,7 +463,7 @@ public async void SearchTeachingEvents_WithFilters_ReturnsEventNarrowlyInRange() } [Fact] - public async void SearchTeachingEvents_WithFilters_ExcludesEventNarrowlyOutOfRange() + public async Task SearchTeachingEvents_WithFilters_ExcludesEventNarrowlyOutOfRange() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -482,7 +482,7 @@ public async void SearchTeachingEvents_WithFilters_ExcludesEventNarrowlyOutOfRan } [Fact] - public async void SearchTeachingEvents_FilteredByRadius_ReturnsMatchingAndOnlineEvents() + public async Task SearchTeachingEvents_FilteredByRadius_ReturnsMatchingAndOnlineEvents() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -492,10 +492,10 @@ public async void SearchTeachingEvents_FilteredByRadius_ReturnsMatchingAndOnline result.Select(e => e.Name).Should().BeEquivalentTo(new string[] { "Event 2", "Event 3", "Event 1", "Event 5" }, options => options.WithStrictOrdering()); - } - + } + [Fact] - public async void SearchTeachingEvents_FilteredByRadiusWithoutPostcode_ReturnsAll() + public async Task SearchTeachingEvents_FilteredByRadiusWithoutPostcode_ReturnsAll() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -509,7 +509,7 @@ public async void SearchTeachingEvents_FilteredByRadiusWithoutPostcode_ReturnsAl } [Fact] - public async void SearchTeachingEvents_FilteredByRadiusWithOutwardOnlyPostcode_ReturnsMatchingAndOnlineEvents() + public async Task SearchTeachingEvents_FilteredByRadiusWithOutwardOnlyPostcode_ReturnsMatchingAndOnlineEvents() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -522,7 +522,7 @@ public async void SearchTeachingEvents_FilteredByRadiusWithOutwardOnlyPostcode_R } [Fact] - public async void SearchTeachingEvents_FilteredByRadiusWithFailedPostcodeGeocoding_ReturnsEmpty() + public async Task SearchTeachingEvents_FilteredByRadiusWithFailedPostcodeGeocoding_ReturnsEmpty() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -534,7 +534,7 @@ public async void SearchTeachingEvents_FilteredByRadiusWithFailedPostcodeGeocodi } [Fact] - public async void SearchTeachingEvents_FilteredByMultipleTypes_ReturnsMatching() + public async Task SearchTeachingEvents_FilteredByMultipleTypes_ReturnsMatching() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -553,7 +553,7 @@ public async void SearchTeachingEvents_FilteredByMultipleTypes_ReturnsMatching() } [Fact] - public async void SearchTeachingEvents_FilteredByType_ReturnsMatching() + public async Task SearchTeachingEvents_FilteredByType_ReturnsMatching() { SeedMockLocations(); await SeedMockTeachingEventsAndBuildingsAsync(); @@ -566,7 +566,7 @@ public async void SearchTeachingEvents_FilteredByType_ReturnsMatching() } [Fact] - public async void SearchTeachingEvents_FilteredByStartAfter_ReturnsMatching() + public async Task SearchTeachingEvents_FilteredByStartAfter_ReturnsMatching() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() { StartAfter = DateTime.UtcNow.AddDays(6) }; @@ -578,7 +578,7 @@ public async void SearchTeachingEvents_FilteredByStartAfter_ReturnsMatching() } [Fact] - public async void SearchTeachingEvents_FilteredByStartBefore_ReturnsMatching() + public async Task SearchTeachingEvents_FilteredByStartBefore_ReturnsMatching() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() { StartBefore = DateTime.UtcNow.AddDays(6) }; @@ -590,7 +590,7 @@ public async void SearchTeachingEvents_FilteredByStartBefore_ReturnsMatching() } [Fact] - public async void SearchTeachingEvents_FilteredByDefaultStatusId_ReturnsOpenAndClosedEvents() + public async Task SearchTeachingEvents_FilteredByDefaultStatusId_ReturnsOpenAndClosedEvents() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest(); @@ -603,7 +603,7 @@ public async void SearchTeachingEvents_FilteredByDefaultStatusId_ReturnsOpenAndC } [Fact] - public async void SearchTeachingEvents_FilteredByStatusId_ReturnsMatching() + public async Task SearchTeachingEvents_FilteredByStatusId_ReturnsMatching() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() @@ -619,7 +619,7 @@ public async void SearchTeachingEvents_FilteredByStatusId_ReturnsMatching() } [Fact] - public async void SearchTeachingEvents_FilteredByMultipleStatusIds_ReturnsMatching() + public async Task SearchTeachingEvents_FilteredByMultipleStatusIds_ReturnsMatching() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() @@ -635,7 +635,7 @@ public async void SearchTeachingEvents_FilteredByMultipleStatusIds_ReturnsMatchi } [Fact] - public async void SearchTeachingEvents_FilteredByOnline_ReturnsOnlyOnlineEvents() + public async Task SearchTeachingEvents_FilteredByOnline_ReturnsOnlyOnlineEvents() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() { Online = true }; @@ -643,10 +643,10 @@ public async void SearchTeachingEvents_FilteredByOnline_ReturnsOnlyOnlineEvents( var result = await _store.SearchTeachingEventsAsync(request); result.Select(e => e.Name).Should().Equal(new string[] { "Event 2", "Event 1", "Event 5" }); - } - + } + [Fact] - public async void SearchTeachingEvents_FilteredByOffline_ReturnsOnlyInPersonEvents() + public async Task SearchTeachingEvents_FilteredByOffline_ReturnsOnlyInPersonEvents() { await SeedMockTeachingEventsAndBuildingsAsync(); var request = new TeachingEventSearchRequest() { Online = false }; @@ -657,7 +657,7 @@ public async void SearchTeachingEvents_FilteredByOffline_ReturnsOnlyInPersonEven } [Fact] - public async void GetTeachingEventAsync_WithId_ReturnsMatchingEvent() + public async Task GetTeachingEventAsync_WithId_ReturnsMatchingEvent() { var events = await SeedMockTeachingEventsAndBuildingsAsync(); var result = await _store.GetTeachingEventAsync((Guid)events.First().Id); @@ -666,14 +666,14 @@ public async void GetTeachingEventAsync_WithId_ReturnsMatchingEvent() result.Building.Should().NotBeNull(); } - [Fact] - public async void GetTeachingEventAsync_WithReadableId_ReturnsMatchingEvent() - { - var events = await SeedMockTeachingEventsAndBuildingsAsync(); - var result = await _store.GetTeachingEventAsync(events.First().ReadableId); - - result.ReadableId.Should().Be(events.First().ReadableId); - result.Building.Should().NotBeNull(); + [Fact] + public async Task GetTeachingEventAsync_WithReadableId_ReturnsMatchingEvent() + { + var events = await SeedMockTeachingEventsAndBuildingsAsync(); + var result = await _store.GetTeachingEventAsync(events.First().ReadableId); + + result.ReadableId.Should().Be(events.First().ReadableId); + result.Building.Should().NotBeNull(); } [Fact] @@ -684,9 +684,9 @@ public async Task GetTeachingEventBuildings_ReturnsAll() var result = _store.GetTeachingEventBuildings().ToList(); result.Should().HaveCount(5); - } - - [Fact] + } + + [Fact] public async Task SaveAsync_WithNewModel_Adds() { var teachingEvent = new TeachingEvent() { Id = Guid.NewGuid(), Name = "TestEvent" }; @@ -698,22 +698,22 @@ public async Task SaveAsync_WithNewModel_Adds() .Should().NotBeNull(); } - [Fact] + [Fact] public async Task SaveAsync_WithExistingModel_Updates() { - var teachingEvent = new TeachingEvent() { Id = Guid.NewGuid(), Name = "TestEvent" }; - - await _store.SaveAsync(teachingEvent); - + var teachingEvent = new TeachingEvent() { Id = Guid.NewGuid(), Name = "TestEvent" }; + + await _store.SaveAsync(teachingEvent); + teachingEvent.Name += "Updated"; - await _store.SaveAsync(teachingEvent); + await _store.SaveAsync(teachingEvent); var teachingEventNames = DbContext.TeachingEvents.Select(e => e.Name).ToList(); teachingEventNames.ForEach(name => name.Should().Contain("Updated")); - } - - [Fact] + } + + [Fact] public async Task SaveAsync_WithModels_Adds() { var teachingEvent1 = new TeachingEvent() { Id = Guid.NewGuid(), Name = "TestEvent1" }; @@ -725,13 +725,13 @@ public async Task SaveAsync_WithModels_Adds() DbContext.TeachingEvents.FirstOrDefault(e => e.Id == teachingEvent2.Id).Should().NotBeNull(); } - private static bool CheckGetTeachingEventsAfterDate(DateTime date) - { - var afterDate = DateTime.UtcNow.Subtract(Store.TeachingEventArchiveSize); - - date.Should().BeCloseTo(afterDate, TimeSpan.FromSeconds(30)); - - return true; + private static bool CheckGetTeachingEventsAfterDate(DateTime date) + { + var afterDate = DateTime.UtcNow.Subtract(Store.TeachingEventArchiveSize); + + date.Should().BeCloseTo(afterDate, TimeSpan.FromSeconds(30)); + + return true; } private static List MockTeachingEvents() @@ -767,8 +767,8 @@ private static List MockTeachingEvents() { Id = Guid.NewGuid(), ReadableId = "3", - StatusId = (int)TeachingEvent.Status.Open, - IsOnline = false, + StatusId = (int)TeachingEvent.Status.Open, + IsOnline = false, Name = "Event 3", StartAt = DateTime.UtcNow.AddDays(10), TypeId = (int)TeachingEvent.EventType.SchoolOrUniversityEvent, @@ -779,7 +779,7 @@ private static List MockTeachingEvents() { Id = Guid.NewGuid(), ReadableId = "4", - StatusId = (int)TeachingEvent.Status.Open, + StatusId = (int)TeachingEvent.Status.Open, IsOnline = false, Name = "Event 4", StartAt = DateTime.UtcNow.AddDays(3), @@ -803,7 +803,7 @@ private static List MockTeachingEvents() Id = Guid.NewGuid(), ReadableId = "6", StatusId = (int)TeachingEvent.Status.Open, - Name = "Event 6", + Name = "Event 6", IsOnline = false, StartAt = DateTime.UtcNow.AddDays(60), TypeId = (int)TeachingEvent.EventType.SchoolOrUniversityEvent, @@ -815,7 +815,7 @@ private static List MockTeachingEvents() Id = Guid.NewGuid(), ReadableId = "7", StatusId = (int)TeachingEvent.Status.Closed, - Name = "Event 7", + Name = "Event 7", IsOnline = false, StartAt = DateTime.UtcNow.AddYears(-1), TypeId = (int)TeachingEvent.EventType.SchoolOrUniversityEvent, @@ -826,11 +826,11 @@ private static List MockTeachingEvents() { Id = Guid.NewGuid(), ReadableId = "8", - Name = "Event 8", + Name = "Event 8", IsOnline = false, TypeId = (int)TeachingEvent.EventType.QuestionTime, StatusId = (int)TeachingEvent.Status.Pending - }; + }; return new List() { event1, event2, event3, event4, event5, event6, event7, event8 }; } @@ -911,8 +911,8 @@ private async Task> SeedMockPrivacyPoliciesAsync() await _store.SyncAsync(); return privacyPolicies; - } - + } + private static IEnumerable MockCountries() { var country1 = new Country() { Id = new Guid("00000000-0000-0000-0000-000000000000"), Value = "Country 1" };