From b8ea5fb92f0e69235b367fb2ad9da0870b8b24b2 Mon Sep 17 00:00:00 2001 From: NPoxon Date: Sun, 8 Sep 2019 15:36:33 +0200 Subject: [PATCH 1/2] Test data cleanup --- .../Api/BookNewConferenceRequestBuilder.cs | 14 +++++++------- .../Builders/Api/ParticipantRequestBuilder.cs | 6 +++--- .../Builders/Domain/ConferenceBuilder.cs | 8 ++++---- .../Steps/CallbackSteps.cs | 1 - .../Steps/ParticipantsSteps.cs | 2 +- ...ConferencesForTodayByUsernameQueryTests.cs | 2 +- .../Steps/ParticipantSteps.cs | 19 +++++++++---------- 7 files changed, 25 insertions(+), 27 deletions(-) diff --git a/VideoAPI/Testing.Common/Helper/Builders/Api/BookNewConferenceRequestBuilder.cs b/VideoAPI/Testing.Common/Helper/Builders/Api/BookNewConferenceRequestBuilder.cs index cd432cb61..2429a5853 100644 --- a/VideoAPI/Testing.Common/Helper/Builders/Api/BookNewConferenceRequestBuilder.cs +++ b/VideoAPI/Testing.Common/Helper/Builders/Api/BookNewConferenceRequestBuilder.cs @@ -19,7 +19,7 @@ public BookNewConferenceRequestBuilder() .With(x => x.CaseType = "Civil Money Claims") .With(x => x.ScheduledDateTime = DateTime.Now) .With(x => x.CaseNumber = $"{GenerateRandom.CaseNumber(fromRandomNumber)}") - .With(x => x.CaseName = $"Automated Test Hearing {GenerateRandom.Letters(fromRandomNumber)}") + .With(x => x.CaseName = $"Video Api Automated Test {GenerateRandom.Letters(fromRandomNumber)}") .With(x => x.ScheduledDuration = 120) .With(x => x.Participants = new List()) .Build(); @@ -28,9 +28,9 @@ public BookNewConferenceRequestBuilder() public BookNewConferenceRequestBuilder WithJudge() { var participant = Builder.CreateNew() - .With(x => x.Name = $"Automation {Name.FullName()}") + .With(x => x.Name = $"Automation_{Name.FullName()}") .With(x => x.Username = $"Automation_{Internet.Email()}") - .With(x => x.DisplayName = $"Automation {Internet.UserName()}") + .With(x => x.DisplayName = $"Automation_{Internet.UserName()}") .With(x => x.UserRole = UserRole.Judge) .With(x => x.ParticipantRefId = Guid.NewGuid()) .Build(); @@ -42,9 +42,9 @@ public BookNewConferenceRequestBuilder WithJudge() public BookNewConferenceRequestBuilder WithRepresentative(string caseTypeGroup = null) { var participant = Builder.CreateNew() - .With(x => x.Name = $"Automation {Name.FullName()}") + .With(x => x.Name = $"Automation_{Name.FullName()}") .With(x => x.Username = $"Automation_{Internet.Email()}") - .With(x => x.DisplayName = $"Automation {Internet.UserName()}") + .With(x => x.DisplayName = $"Automation_{Internet.UserName()}") .With(x => x.UserRole = UserRole.Representative) .With(x => x.Representee = "Person") .With(x => x.ParticipantRefId = Guid.NewGuid()) @@ -62,9 +62,9 @@ public BookNewConferenceRequestBuilder WithRepresentative(string caseTypeGroup = public BookNewConferenceRequestBuilder WithIndividual(string caseTypeGroup = null) { var participant = Builder.CreateNew() - .With(x => x.Name = $"Automation {Name.FullName()}") + .With(x => x.Name = $"Automation_{Name.FullName()}") .With(x => x.Username = $"Automation_{Internet.Email()}") - .With(x => x.DisplayName = $"Automation {Internet.UserName()}") + .With(x => x.DisplayName = $"Automation_{Internet.UserName()}") .With(x => x.UserRole = UserRole.Individual) .With(x => x.ParticipantRefId = Guid.NewGuid()) .Build(); diff --git a/VideoAPI/Testing.Common/Helper/Builders/Api/ParticipantRequestBuilder.cs b/VideoAPI/Testing.Common/Helper/Builders/Api/ParticipantRequestBuilder.cs index ca7555ef6..cabde615e 100644 --- a/VideoAPI/Testing.Common/Helper/Builders/Api/ParticipantRequestBuilder.cs +++ b/VideoAPI/Testing.Common/Helper/Builders/Api/ParticipantRequestBuilder.cs @@ -12,9 +12,9 @@ public class ParticipantRequestBuilder public ParticipantRequestBuilder(UserRole userRole) { _participantRequest = Builder.CreateNew() - .With(x => x.Name = Name.FullName()) - .With(x => x.Username = Internet.Email()) - .With(x => x.DisplayName = Internet.UserName()) + .With(x => x.Name = $"Automation_{Name.FullName()}") + .With(x => x.Username = $"Automation_{Internet.Email()}") + .With(x => x.DisplayName = $"Automation_{Internet.UserName()}") .With(x => x.UserRole = userRole) .Build(); } diff --git a/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs b/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs index b18969645..636be3eee 100644 --- a/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs +++ b/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs @@ -29,8 +29,8 @@ public ConferenceBuilder(bool ignoreId = false, Guid? knownHearingRefId = null, var scheduleDateTime = scheduledDateTime ?? DateTime.UtcNow.AddMinutes(30); const string caseType = "Civil Money Claims"; - var caseNumber = $"Test{Guid.NewGuid():N}"; - const string caseName = "Auto vs Manual"; + var caseNumber = $"{GenerateRandom.CaseNumber(new Random())}"; + const string caseName = "Video Api Integration Test"; const int scheduledDuration = 120; _conference = new Conference(hearingRefId, caseType, scheduleDateTime, caseNumber, caseName, scheduledDuration); } @@ -53,10 +53,10 @@ public ConferenceBuilder WithParticipant(UserRole userRole, string caseTypeGroup { if (string.IsNullOrWhiteSpace(username)) { - username = Internet.Email(); + username = $"Automation_{Internet.Email()}"; } var participant = new Builder(_builderSettings).CreateNew().WithFactory(() => - new Participant(Guid.NewGuid(), Name.FullName(), Name.First(), username, userRole, + new Participant(Guid.NewGuid(), $"Automation_{Name.FullName()}", $"Automation_{Name.First()}", username, userRole, caseTypeGroup)).Build(); if (userRole == UserRole.Representative) diff --git a/VideoAPI/VideoApi.AcceptanceTests/Steps/CallbackSteps.cs b/VideoAPI/VideoApi.AcceptanceTests/Steps/CallbackSteps.cs index 561fce4a3..5b48e0d94 100644 --- a/VideoAPI/VideoApi.AcceptanceTests/Steps/CallbackSteps.cs +++ b/VideoAPI/VideoApi.AcceptanceTests/Steps/CallbackSteps.cs @@ -6,7 +6,6 @@ using Testing.Common.Helper; using VideoApi.AcceptanceTests.Contexts; using VideoApi.Common.Helpers; -using VideoApi.Common.Security.CustomToken; using VideoApi.Contract.Requests; using VideoApi.Contract.Responses; using VideoApi.Domain.Enums; diff --git a/VideoAPI/VideoApi.AcceptanceTests/Steps/ParticipantsSteps.cs b/VideoAPI/VideoApi.AcceptanceTests/Steps/ParticipantsSteps.cs index f1024b174..0286b8830 100644 --- a/VideoAPI/VideoApi.AcceptanceTests/Steps/ParticipantsSteps.cs +++ b/VideoAPI/VideoApi.AcceptanceTests/Steps/ParticipantsSteps.cs @@ -51,7 +51,7 @@ public void ThenTheParticipantIsAdded(string state) _context.Response.IsSuccessful.Should().BeTrue(); var conference = ApiRequestHelper.DeserialiseSnakeCaseJsonToResponse(_context.Response.Content); conference.Should().NotBeNull(); - var exists = conference.Participants.Any(participant => participant.Username == _scenarioContext.Get(ParticipantUsernameKey)); + var exists = conference.Participants.Any(participant => participant.Username.ToLower().Equals(_scenarioContext.Get(ParticipantUsernameKey).ToLower())); if (state.Equals("added")) { exists.Should().BeTrue(); diff --git a/VideoAPI/VideoApi.IntegrationTests/Database/Queries/GetConferencesForTodayByUsernameQueryTests.cs b/VideoAPI/VideoApi.IntegrationTests/Database/Queries/GetConferencesForTodayByUsernameQueryTests.cs index a94cd6027..3e318b627 100644 --- a/VideoAPI/VideoApi.IntegrationTests/Database/Queries/GetConferencesForTodayByUsernameQueryTests.cs +++ b/VideoAPI/VideoApi.IntegrationTests/Database/Queries/GetConferencesForTodayByUsernameQueryTests.cs @@ -38,7 +38,7 @@ public void Setup() [Test] public async Task should_get_conference_for_username() { - var username = "knownuser@email.com"; + var username = "Automation_knownuser@email.com"; var conference1 = new ConferenceBuilder(true) .WithParticipant(UserRole.Representative, "Defendant", username) .WithParticipant(UserRole.Judge, null) diff --git a/VideoAPI/VideoApi.IntegrationTests/Steps/ParticipantSteps.cs b/VideoAPI/VideoApi.IntegrationTests/Steps/ParticipantSteps.cs index cbabf4a4e..f80dafb68 100644 --- a/VideoAPI/VideoApi.IntegrationTests/Steps/ParticipantSteps.cs +++ b/VideoAPI/VideoApi.IntegrationTests/Steps/ParticipantSteps.cs @@ -9,7 +9,6 @@ using Testing.Common.Helper.Builders.Api; using VideoApi.Common.Helpers; using VideoApi.Contract.Requests; -using VideoApi.Domain; using VideoApi.Domain.Enums; using VideoApi.IntegrationTests.Contexts; using VideoApi.IntegrationTests.Helper; @@ -93,9 +92,9 @@ public async Task GivenIHaveAnUpdateParticipantToConferenceRequest(Scenario scen participantId = seededConference.Participants.First().Id; request = new UpdateParticipantRequest { - Fullname = "Mr Test_Fullname", - DisplayName = "Test_Displayname", - Representee = "Test_Representee" + Fullname = "Automation_Mr Test_Fullname", + DisplayName = "Automation_Test_Displayname", + Representee = "Automation_Test_Representee" }; break; } @@ -105,18 +104,18 @@ public async Task GivenIHaveAnUpdateParticipantToConferenceRequest(Scenario scen participantId = Guid.NewGuid(); request = new UpdateParticipantRequest { - Fullname = "Mr Test_Fullname", - DisplayName = "Test_Displayname", - Representee = "Test_Representee" + Fullname = "Automation_Mr Test_Fullname", + DisplayName = "Automation_Test_Displayname", + Representee = "Automation_Test_Representee" }; break; case Scenario.Invalid: conferenceId = Guid.Empty; request = new UpdateParticipantRequest { - Fullname = "Mr Test_Fullname", - DisplayName = "Test_Displayname", - Representee = "Test_Representee" + Fullname = "Automation_Mr Test_Fullname", + DisplayName = "Automation_Test_Displayname", + Representee = "Automation_Test_Representee" }; break; From f79c6cf88b36eeef5cc14d051932d29f2354825b Mon Sep 17 00:00:00 2001 From: NPoxon Date: Sun, 8 Sep 2019 15:51:04 +0200 Subject: [PATCH 2/2] Removed changes as failing unit tests --- .../Helper/Builders/Domain/ConferenceBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs b/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs index 636be3eee..93eeb1f93 100644 --- a/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs +++ b/VideoAPI/Testing.Common/Helper/Builders/Domain/ConferenceBuilder.cs @@ -53,10 +53,10 @@ public ConferenceBuilder WithParticipant(UserRole userRole, string caseTypeGroup { if (string.IsNullOrWhiteSpace(username)) { - username = $"Automation_{Internet.Email()}"; + username = Internet.Email(); } var participant = new Builder(_builderSettings).CreateNew().WithFactory(() => - new Participant(Guid.NewGuid(), $"Automation_{Name.FullName()}", $"Automation_{Name.First()}", username, userRole, + new Participant(Guid.NewGuid(), Name.FullName(), Name.First(), username, userRole, caseTypeGroup)).Build(); if (userRole == UserRole.Representative)