public async Task GivenWhenICreateATournamentWithTheFollowingDetails(Table table) { foreach (TableRow tableRow in table.Rows) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(tableRow["GolfClubNumber"]); List <MeasuredCourseListResponse> measuredCourseList = await this.TestingContext.DockerHelper.GolfClubClient.GetMeasuredCourses(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); MeasuredCourseListResponse measuredCourse = measuredCourseList.Single(m => m.Name == tableRow["MeasuredCourseName"]); TournamentFormat tournamentFormat = Enum.Parse <TournamentFormat>(tableRow["TournamentFormat"], true); PlayerCategory playerCategory = Enum.Parse <PlayerCategory>(tableRow["PlayerCategory"], true); // Work out the tournament date DateTime tournamentDate = this.CalculateTournamentDate(tableRow); CreateTournamentRequest createTournamentRequest = new CreateTournamentRequest { Format = (Int32)tournamentFormat, Name = tableRow["TournamentName"], MeasuredCourseId = measuredCourse.MeasuredCourseId, MemberCategory = (Int32)playerCategory, TournamentDate = tournamentDate }; this.TestingContext.CreateTournamentRequests.Add(new Tuple <String, String, String>(tableRow["GolfClubNumber"], tableRow["MeasuredCourseName"], tableRow["TournamentNumber"]), createTournamentRequest); } }
public async Task ThenUsersDetailsAreReturnedForGolfClub(Int32 numberOfUsers, String golfClubNumber) { if (this.TestingContext.GetGolfClubUserListResponse.Count != numberOfUsers) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); await Retry.For(async() => { this.TestingContext.GetGolfClubUserListResponse = await this.TestingContext.DockerHelper.GolfClubClient .GetGolfClubUserList(this.TestingContext .GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); if (this.TestingContext.GetGolfClubUserListResponse.Count != numberOfUsers) { throw new Exception(); } }); } this.TestingContext.GetGolfClubUserListResponse.ShouldNotBeNull(); this.TestingContext.GetGolfClubUserListResponse.ShouldNotBeEmpty(); this.TestingContext.GetGolfClubUserListResponse.Count.ShouldBe(numberOfUsers); }
public async Task WhenIRequestANumberOfMembersByHandicapCategoryReportForClubNumber(String golfClubNumber) { CreateGolfClubResponse golfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); this.TestingContext.GetNumberOfMembersByHandicapCategoryReportResponse = await this.TestingContext.DockerHelper.ReportingClient.GetNumberOfMembersByHandicapCategoryReport(this.TestingContext.GolfClubAdministratorToken, golfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); }
public async Task WhenIRequestAListOfUsersForTheForGolfClub(String golfClubNumber) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); this.TestingContext.GetGolfClubUserListResponse = await this.TestingContext.DockerHelper.GolfClubClient.GetGolfClubUserList(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); }
public async Task WhenIRequestAListOfMembersForGolfClubNumber(String golfClubNumber) { CreateGolfClubResponse golfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); this.TestingContext.GolfClubMembersList = await this.TestingContext.DockerHelper.GolfClubClient.GetGolfClubMembershipList(this.TestingContext.GolfClubAdministratorToken, golfClubResponse.GolfClubId, CancellationToken.None); }
public async Task WhenIGetTheTournamentListForGolfClub(String golfClubNumber) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); List <TournamentResponse> tournamentList = await this.TestingContext.DockerHelper.GolfClubClient .GetGolfClubTournamentList(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); this.TestingContext.GetTournamentListResponses.Add(golfClubNumber, tournamentList); }
public void ThenTheDivsionIsAdddedSuccessfullyToGolfClub(String golfClubNumber) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); Should.NotThrow(async() => { await this.TestingContext.DockerHelper.GolfClubClient.AddTournamentDivision(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, this.TestingContext.AddTournamentDivisionToGolfClubRequest, CancellationToken.None).ConfigureAwait(false); }); }
public void WhenIRequestToProduceATournamentResultForTournamentNumberForGolfClubMeasuredCourseTheResultsAreProduced(String tournamentNumber, String golfClubNumber, String measuredCourseName) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); CreateTournamentResponse createTournamentResponse = this.TestingContext.GetCreateTournamentResponse(golfClubNumber, measuredCourseName, tournamentNumber); Should.NotThrow(async() => { await this.TestingContext.DockerHelper.GolfClubClient .ProduceTournamentResult(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, createTournamentResponse.TournamentId, CancellationToken.None) .ConfigureAwait(false); }); }
public async Task WhenIAskForAListOfMeasuredCoursesAgainstTheGolfClub(String golfClubNumber) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.CreateGolfClubResponses[golfClubNumber]; await Retry.For(async() => { List <MeasuredCourseListResponse> response = await this.TestingContext.DockerHelper.GolfClubClient.GetMeasuredCourses(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); this.TestingContext.MeasuredCourseList = response; }).ConfigureAwait(false); }
public void WhenIRequestMembershipOfClubNumberForPlayerNumberTheRequestIsSuccessful(String clubNumber, String playerNumber) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(clubNumber); RegisterPlayerResponse registerPlayerResponse = this.TestingContext.GetRegisterPlayerResponse(playerNumber); Should.NotThrow(async() => { await this.TestingContext.DockerHelper.PlayerClient.RequestClubMembership(this.TestingContext.PlayerToken, registerPlayerResponse.PlayerId, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); }); }
public async Task ThenTheNumberOfMembersOnTheMembersHandicapListClubNumberIs(String golfClubNumber, Int32 numberOfMembers) { CreateGolfClubResponse golfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); await Retry.For(async() => { this.TestingContext.GetMembersHandicapListReportResponse = await this .TestingContext.DockerHelper.ReportingClient .GetMembersHandicapListReport(this.TestingContext.GolfClubAdministratorToken, golfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); this.TestingContext.GetMembersHandicapListReportResponse.MembersHandicapListReportResponse.Count.ShouldBe(numberOfMembers); }); }
public async Task ThenTournamentNumberForGolfClubMeasuredCourseWillBeCreated(String tournamentNumber, String golfClubNumber, String measuredCourseName) { CreateTournamentRequest createTournamentRequest = this.TestingContext.GetCreateTournamentRequest(golfClubNumber, measuredCourseName, tournamentNumber); CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); CreateTournamentResponse createTournamentResponse = await this.TestingContext.DockerHelper.GolfClubClient .CreateTournament(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, createTournamentRequest, CancellationToken.None) .ConfigureAwait(false); createTournamentResponse.TournamentId.ShouldNotBe(Guid.Empty); this.TestingContext.CreateTournamentResponses.Add(new Tuple <String, String, String>(golfClubNumber, measuredCourseName, tournamentNumber), createTournamentResponse); }
public async Task ThenTournamentRecordWillBeReturnedForGolfClub(Int32 numberOfTournaments, String golfClubNumber) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); await Retry.For(async() => { List <TournamentResponse> tournamentList = await this.TestingContext.DockerHelper.GolfClubClient .GetGolfClubTournamentList(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); tournamentList.Count.ShouldBe(numberOfTournaments); this.TestingContext.GetTournamentListResponses.Remove(golfClubNumber); this.TestingContext.GetTournamentListResponses.Add(golfClubNumber, tournamentList); }); }
public void ThenTheMeasuredCourseIsAddedToTheClubSuccessfully() { foreach (KeyValuePair <KeyValuePair <String, String>, AddMeasuredCourseToClubRequest> addMeasuredCourseToClubRequest in this .TestingContext .AddMeasuredCourseToClubRequests) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.CreateGolfClubResponses[addMeasuredCourseToClubRequest.Key.Key]; Should.NotThrow(async() => { await this.TestingContext.DockerHelper.GolfClubClient.AddMeasuredCourseToGolfClub(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, addMeasuredCourseToClubRequest.Value, CancellationToken.None).ConfigureAwait(false); }); } }
public async Task ThenTheNumberOfMembersByHandicapCategoryCountForClubNumberHandicapCategoryIs(String golfClubNumber, Int32 handicapCategory, Int32 membersCount) { CreateGolfClubResponse golfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); await Retry.For(async() => { this.TestingContext.GetNumberOfMembersByHandicapCategoryReportResponse = await this.TestingContext.DockerHelper.ReportingClient.GetNumberOfMembersByHandicapCategoryReport(this.TestingContext.GolfClubAdministratorToken, golfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); MembersByHandicapCategoryResponse membersByHandicapCategoryResponse = this.TestingContext.GetNumberOfMembersByHandicapCategoryReportResponse.MembersByHandicapCategoryResponse.SingleOrDefault(h => h.HandicapCategory == handicapCategory); membersByHandicapCategoryResponse.ShouldNotBeNull(); membersByHandicapCategoryResponse.NumberOfMembers.ShouldBe(membersCount); }); }
public async Task GolfClubClient_CreateGolfClub_GolfClubIsCreated() { // 1. Arrange HttpClient client = this.WebApplicationFactory.AddGolfClubAdministrator().CreateClient(); Func <String, String> resolver = api => "http://localhost"; IGolfClubClient golfClubClient = new GolfClubClient(resolver, client); CreateGolfClubRequest createGolfClubRequest = TestData.CreateGolfClubRequest; String token = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImVhZDQyNGJjNjI5MzU0NGM4MGFmZThhMDk2MzEyNjU2IiwidHlwIjoiSldUIn0.eyJuYmYiOjE1NzAyODk3MDksImV4cCI6MTU3MDI5MzMwOSwiaXNzIjoiaHR0cDovLzE5Mi4xNjguMS4xMzI6NTAwMSIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjEzMjo1MDAxL3Jlc291cmNlcyIsIm1hbmFnZW1lbnRhcGkiLCJzZWN1cmlydHlzZXJ2aWNlYXBpIl0sImNsaWVudF9pZCI6ImdvbGZoYW5kaWNhcC50ZXN0ZGF0YWdlbmVyYXRvciIsInNjb3BlIjpbIm1hbmFnZW1lbnRhcGkiLCJzZWN1cmlydHlzZXJ2aWNlYXBpIl19.vLfs2bOMXshW93nw5TTOqd6NPGNYpcrhcom8yZoYc9WGSuYH48VqM5BdbodEukNNJmgbV9wUVgoj1uGztlFfHGFA_q6IQfd3xZln_LIxju6ZNZs8qUyRXDTGxu0dlfF8STLfBUq469SsY9eNi1hBYFyNxl963OfKqDSHAdeBg9yNlwnbky1Tnsxobu9W33fLcjH0KoutlwTFV51UFUEKCBk0w1zsjaDVZacETn74t56y0CvMS7ZSN2_yyunq4JvoUsh3xM5lQ-gl23eQyo6l4QE4wukCS7U_Zr2dg8-EF63VKiCH-ZD49M76TD9kIIge-XIgHqa2Xf3S-FpLxXfEqw"; // 2. Act CreateGolfClubResponse createGolfClubResponse = await golfClubClient.CreateGolfClub(token, createGolfClubRequest, CancellationToken.None); // 3. Assert createGolfClubResponse.GolfClubId.ShouldBe(TestData.GolfClubId); }
public void WhenIRequestToCancelTheTournamentNumberForGolfClubMeasuredCourseTheTournamentIsCancelled(String tournamentNumber, String golfClubNumber, String measuredCourseName) { CreateGolfClubResponse createGolfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); CreateTournamentResponse createTournamentResponse = this.TestingContext.GetCreateTournamentResponse(golfClubNumber, measuredCourseName, tournamentNumber); CancelTournamentRequest cancelTournamentRequest = new CancelTournamentRequest { CancellationReason = "Test Cancel" }; Should.NotThrow(async() => { await this.TestingContext.DockerHelper.GolfClubClient.CancelTournament(this.TestingContext.GolfClubAdministratorToken, createGolfClubResponse.GolfClubId, createTournamentResponse.TournamentId, cancelTournamentRequest, CancellationToken.None).ConfigureAwait(false); }); }
public async Task ThenTheNumberOfMembersForThePeriodInTheNumberOfMembersByTimePeriodReportForClubNumberIs(String periodString, String timePeriod, String golfClubNumber, Int32 membersCount) { CreateGolfClubResponse golfClubResponse = this.TestingContext.GetCreateGolfClubResponse(golfClubNumber); await Retry.For(async() => { this.TestingContext.GetNumberOfMembersByTimePeriodReportResponse = await this .TestingContext.DockerHelper.ReportingClient .GetNumberOfMembersByTimePeriodReport(this.TestingContext.GolfClubAdministratorToken, golfClubResponse.GolfClubId, timePeriod, CancellationToken.None).ConfigureAwait(false); String periodValue = this.GetPeriodFromPeriodString(periodString); MembersByTimePeriodResponse membersByTimePeriodResponse = this.TestingContext.GetNumberOfMembersByTimePeriodReportResponse.MembersByTimePeriodResponse .SingleOrDefault(h => h.Period == periodValue); membersByTimePeriodResponse.ShouldNotBeNull(); membersByTimePeriodResponse.NumberOfMembers.ShouldBe(membersCount); }); }
public async Task GivenTheFollowingPlayersAreClubMembersOfTheFollowingGolfClubs(Table table) { foreach (TableRow tableRow in table.Rows) { RegisterPlayerRequest registerPlayerRequest = this.TestingContext.GetRegisterPlayerRequest(tableRow["PlayerNumber"]); RegisterPlayerResponse registerPlayerResponse = this.TestingContext.GetRegisterPlayerResponse(tableRow["PlayerNumber"]); CreateGolfClubResponse golfClubResponse = this.TestingContext.GetCreateGolfClubResponse(tableRow["GolfClubNumber"]); this.TestingContext.PlayerToken = await this.TestingContext.DockerHelper.GetToken(TokenType.Password, "golfhandicap.mobile", "golfhandicap.mobile", registerPlayerRequest.EmailAddress, "123456").ConfigureAwait(false); await this.TestingContext.DockerHelper.PlayerClient.RequestClubMembership(this.TestingContext.PlayerToken, registerPlayerResponse.PlayerId, golfClubResponse.GolfClubId, CancellationToken.None).ConfigureAwait(false); } }
public async Task GivenTheFollowingGolfClubsExist(Table table) { foreach (TableRow tableRow in table.Rows) { RegisterClubAdministratorRequest registerClubAdministratorRequest = this.TestingContext.GetRegisterClubAdministratorRequest(tableRow["GolfClubNumber"]); this.TestingContext.GolfClubAdministratorToken = await this.TestingContext.DockerHelper.GetToken(TokenType.Password, "golfhandicap.mobile", "golfhandicap.mobile", registerClubAdministratorRequest.EmailAddress, registerClubAdministratorRequest.Password).ConfigureAwait(false); ; CreateGolfClubRequest createGolfClubRequest = new CreateGolfClubRequest { AddressLine1 = tableRow["AddressLine1"], EmailAddress = tableRow["EmailAddress"], TelephoneNumber = tableRow["TelephoneNumber"], Name = tableRow["GolfClubName"], AddressLine2 = tableRow["AddressLine2"], PostalCode = tableRow["PostalCode"], Region = tableRow["Region"], Town = tableRow["Town"], Website = tableRow["WebSite"] }; this.TestingContext.CreateGolfClubRequests.Add(tableRow["GolfClubNumber"], createGolfClubRequest); CreateGolfClubResponse createGolfClubResponse = await this.TestingContext.DockerHelper.GolfClubClient.CreateGolfClub(this.TestingContext.GolfClubAdministratorToken, createGolfClubRequest, CancellationToken.None).ConfigureAwait(false); this.TestingContext.CreateGolfClubResponses.Add(tableRow["GolfClubNumber"], createGolfClubResponse); } }
/// <summary> /// Creates the golf club. /// </summary> /// <param name="accessToken">The access token.</param> /// <param name="request">The request.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public async Task <CreateGolfClubResponse> CreateGolfClub(String accessToken, CreateGolfClubRequest request, CancellationToken cancellationToken) { CreateGolfClubResponse response = null; String requestUri = $"{this.BaseAddress}/api/golfclubs"; try { String requestSerialised = JsonConvert.SerializeObject(request); StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); // Add the access token to the client headers this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); // Make the Http Call here HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); // Process the response String content = await this.HandleResponse(httpResponse, cancellationToken); // call was successful so now deserialise the body to the response object response = JsonConvert.DeserializeObject <CreateGolfClubResponse>(content); } catch (Exception ex) { // An exception has occurred, add some additional information to the message Exception exception = new Exception($"Error creating the new golf club {request.Name}.", ex); throw exception; } return(response); }
/// <summary> /// Creates the golf club datav2. /// </summary> /// <param name="testDataGenerator">The test data generator.</param> /// <param name="numberOfGolfClubs">The number of golf clubs.</param> /// <param name="lastClubCount">The last club count.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> private static async Task CreateGolfClubDatav2(ITestDataGenerator testDataGenerator, Int32 numberOfGolfClubs, Int32 lastClubCount, CancellationToken cancellationToken) { List <Task> tasks = new List <Task>(); Int32 startIndex = 0 + lastClubCount; Int32 endIndex = numberOfGolfClubs + lastClubCount; for (Int32 i = startIndex; i < endIndex; i++) { RegisterClubAdministratorRequest registerClubAdministratorRequest = new RegisterClubAdministratorRequest { EmailAddress = $"clubadministrator@testgolfclub{i}.co.uk", ConfirmPassword = "******", Password = "******", TelephoneNumber = "1234567890", FamilyName = $"Admin {i}", GivenName = "Club" }; await testDataGenerator.RegisterGolfClubAdministrator(registerClubAdministratorRequest, cancellationToken); String clubAdministratorToken = await testDataGenerator.GetToken(TokenType.Password, "developerClient", "developerClient", registerClubAdministratorRequest.EmailAddress, registerClubAdministratorRequest.Password, new List <String> { "openid", "profile", "managementapi" }); CreateGolfClubRequest createGolfClubRequest = new CreateGolfClubRequest { AddressLine1 = "Address Line 1", AddressLine2 = "Address Line 2", EmailAddress = $"contactus@testgolfclub{i}.co.uk", TelephoneNumber = "1234567890", Name = $"Test Golf Club {i}", PostalCode = "TE57 1NG", Region = "TestRegion", Town = "TestTown", Website = string.Empty }; CreateGolfClubResponse createGolfClubResponse = await testDataGenerator.CreateGolfClub(clubAdministratorToken, createGolfClubRequest, cancellationToken); await testDataGenerator.AddMeasuredCourseToGolfClub(Program.accessToken, createGolfClubResponse.GolfClubId, Program.AddMeasuredCourseToClubRequest, cancellationToken); AddTournamentDivisionToGolfClubRequest division1 = new AddTournamentDivisionToGolfClubRequest { Division = 1, StartHandicap = -10, EndHandicap = 7 }; await testDataGenerator.AddTournamentDivision(Program.accessToken, createGolfClubResponse.GolfClubId, division1, cancellationToken); AddTournamentDivisionToGolfClubRequest division2 = new AddTournamentDivisionToGolfClubRequest { Division = 2, StartHandicap = 6, EndHandicap = 12 }; await testDataGenerator.AddTournamentDivision(Program.accessToken, createGolfClubResponse.GolfClubId, division2, cancellationToken); AddTournamentDivisionToGolfClubRequest division3 = new AddTournamentDivisionToGolfClubRequest { Division = 3, StartHandicap = 13, EndHandicap = 21 }; await testDataGenerator.AddTournamentDivision(Program.accessToken, createGolfClubResponse.GolfClubId, division3, cancellationToken); AddTournamentDivisionToGolfClubRequest division4 = new AddTournamentDivisionToGolfClubRequest { Division = 4, StartHandicap = 22, EndHandicap = 28 }; await testDataGenerator.AddTournamentDivision(Program.accessToken, createGolfClubResponse.GolfClubId, division4, cancellationToken); Program.GolfClubs.Add(new GolfClubDetails { AdminEmailAddress = registerClubAdministratorRequest.EmailAddress, AdminPassword = registerClubAdministratorRequest.Password, GolfClubId = createGolfClubResponse.GolfClubId, MeasuredCourseId = Program.AddMeasuredCourseToClubRequest.MeasuredCourseId, GolfClubName = createGolfClubRequest.Name }); } }