/// <summary> /// Registers the golf club administrator. /// </summary> /// <param name="request">The request.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public async Task RegisterGolfClubAdministrator(RegisterClubAdministratorRequest request, CancellationToken cancellationToken) { String requestUri = $"{this.BaseAddress}/api/GolfClub/RegisterGolfClubAdministrator"; try { String requestSerialised = JsonConvert.SerializeObject(request); StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); // 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, no response data to deserialise } catch (Exception ex) { // An exception has occurred, add some additional information to the message Exception exception = new Exception("Error registering a Golf Club Administrator.", ex); throw exception; } }
public async Task GolfClubAdministratorController_POST_GolfClubAdministrator_GolfClubAdministratorIsReturned() { // 1. Arrange HttpClient client = this.WebApplicationFactory.CreateClient(); RegisterClubAdministratorRequest registerClubAdministratorRequest = TestData.RegisterClubAdministratorRequest; String uri = "api/golfclubadministrators/"; StringContent content = Helpers.CreateStringContent(registerClubAdministratorRequest); client.DefaultRequestHeaders.Add("api-version", "2.0"); // 2. Act HttpResponseMessage response = await client.PostAsync(uri, content, CancellationToken.None); // 3. Assert response.StatusCode.ShouldBe(HttpStatusCode.Created); String responseAsJson = await response.Content.ReadAsStringAsync(); responseAsJson.ShouldNotBeNullOrEmpty(); RegisterClubAdministratorResponse responseObject = JsonConvert.DeserializeObject <RegisterClubAdministratorResponse>(responseAsJson); responseObject.ShouldNotBeNull(); responseObject.GolfClubAdministratorId.ShouldBe(TestData.GolfClubAdministratorUserId); }
/// <summary> /// Handles the SignUpButtonClick event of the SignupPageGolfClubAdministrator1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private async void SignupPageGolfClubAdministrator1_SignUpButtonClick(Object sender, EventArgs e) { try { RegisterClubAdministratorRequest request = new RegisterClubAdministratorRequest { EmailAddress = this.SignupPageGolfClubAdministrator1ViewModel.EmailAddress, TelephoneNumber = this.SignupPageGolfClubAdministrator1ViewModel.TelephoneNumber, Password = this.SignupPageGolfClubAdministrator1ViewModel.Password, ConfirmPassword = this.SignupPageGolfClubAdministrator1ViewModel.Password }; await this.GolfClubClient.RegisterGolfClubAdministrator(request, CancellationToken.None); await App.Current.MainPage.DisplayAlert("Success", $"Registration Successful", "OK"); await this.NavigationService.PopToRootPage(); } catch (Exception ex) { // TODO: log the error await App.Current.MainPage.DisplayAlert("Failure", $"Registration Failed", "OK"); } }
public void ThenTheGolfClubAdministratorsDetailsAreReturnedForGolfClub(String golfClubNumber) { RegisterClubAdministratorRequest registerClubAdministratorRequest = this.TestingContext.GetRegisterClubAdministratorRequest(golfClubNumber); GolfClubUserResponse user = this.TestingContext.GetGolfClubUserListResponse.SingleOrDefault(u => u.Email == registerClubAdministratorRequest.EmailAddress); user.ShouldNotBeNull(); }
/// <summary> /// Registers the golf club administrator. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="cancellationToken">The cancellation token.</param> public async Task RegisterGolfClubAdministrator(RegisterClubAdministratorViewModel viewModel, CancellationToken cancellationToken) { // Translate view model to request RegisterClubAdministratorRequest registerRegisterClubAdministratorRequest = this.ModelFactory.ConvertFrom(viewModel); await this.GolfClubClient.RegisterGolfClubAdministrator(registerRegisterClubAdministratorRequest, cancellationToken); }
public async Task <IActionResult> RegisterGolfClubAdministrator([FromBody] RegisterClubAdministratorRequest request, CancellationToken cancellationToken) { await this.Manager.RegisterClubAdministrator(request, cancellationToken); // return the result return(this.NoContent()); }
public async Task GivenIAmLoggedInAsAGolfClubAdministratorForGolfClub(String golfClubNumber) { RegisterClubAdministratorRequest registerClubAdministratorRequest = this.TestingContext.GetRegisterClubAdministratorRequest(golfClubNumber); this.TestingContext.GolfClubAdministratorToken = await this.TestingContext.DockerHelper.GetToken(TokenType.Password, "golfhandicap.mobile", "golfhandicap.mobile", registerClubAdministratorRequest.EmailAddress, registerClubAdministratorRequest.Password).ConfigureAwait(false); }
public async Task <IActionResult> PostGolfClubAdministrator([FromBody] RegisterClubAdministratorRequest registerClubAdministratorRequest, CancellationToken cancellationToken) { Guid golfClubAdministratorId = await this.Manager.RegisterClubAdministrator(registerClubAdministratorRequest, cancellationToken); return(this.Created($"api/{GolfClubAdministratorController.ControllerName}/{golfClubAdministratorId}", new RegisterClubAdministratorResponse { GolfClubAdministratorId = golfClubAdministratorId })); }
public void ModelFactory_ConvertFrom_RegisterClubAdministratorViewModel_ConvertedSuccessfully() { ModelFactory factory = new ModelFactory(); RegisterClubAdministratorViewModel viewModel = ModelFactoryTestData.GetRegisterClubAdministratorViewModel(); RegisterClubAdministratorRequest request = factory.ConvertFrom(viewModel); request.ConfirmPassword.ShouldBe(viewModel.ConfirmPassword); request.EmailAddress.ShouldBe(viewModel.Email); request.Password.ShouldBe(viewModel.Password); request.TelephoneNumber.ShouldBe(viewModel.TelephoneNumber); }
/// <summary> /// Converts from. /// </summary> /// <param name="viewModel">The view model.</param> /// <returns></returns> public RegisterClubAdministratorRequest ConvertFrom(RegisterClubAdministratorViewModel viewModel) { RegisterClubAdministratorRequest registerRegisterClubAdministratorRequest = new RegisterClubAdministratorRequest { ConfirmPassword = viewModel.ConfirmPassword, EmailAddress = viewModel.Email, Password = viewModel.Password, TelephoneNumber = viewModel.TelephoneNumber, FamilyName = viewModel.LastName, GivenName = viewModel.FirstName, MiddleName = string.Empty }; return(registerRegisterClubAdministratorRequest); }
public async Task GolfClubAdministratorClient_RegisterGolfClubAdministrator_GolfClubAdministratorIsCreated() { // 1. Arrange HttpClient client = this.WebApplicationFactory.CreateClient(); Func <String, String> resolver = api => "http://localhost"; IGolfClubAdministratorClient golfClubAdministratorClient = new GolfClubAdministratorClient(resolver, client); RegisterClubAdministratorRequest registerClubAdministratorRequest = TestData.RegisterClubAdministratorRequest; // 2. Act RegisterClubAdministratorResponse registerClubAdministratorResponse = await golfClubAdministratorClient.RegisterGolfClubAdministrator(registerClubAdministratorRequest, CancellationToken.None); // 3. Assert registerClubAdministratorResponse.GolfClubAdministratorId.ShouldBe(TestData.GolfClubAdministratorUserId); }
public void WhenIRegisterTheFollowingDetailsForAGolfClubAdministrator(Table table) { TableRow tableRow = table.Rows.Single(); RegisterClubAdministratorRequest registerClubAdministratorRequest = new RegisterClubAdministratorRequest { ConfirmPassword = tableRow["ConfirmPassword"], FamilyName = tableRow["FamilyName"], GivenName = tableRow["GivenName"], MiddleName = tableRow["MiddleName"], EmailAddress = tableRow["EmailAddress"], TelephoneNumber = tableRow["TelephoneNumber"], Password = tableRow["Password"] }; this.TestingContext.RegisterClubAdministratorRequest = registerClubAdministratorRequest; }
public async Task GivenTheFollowingGolfClubAdministratorsHaveBeenRegistered(Table table) { foreach (TableRow tableRow in table.Rows) { RegisterClubAdministratorRequest registerClubAdministratorRequest = new RegisterClubAdministratorRequest { ConfirmPassword = tableRow["ConfirmPassword"], FamilyName = tableRow["FamilyName"], GivenName = tableRow["GivenName"], MiddleName = tableRow["MiddleName"], EmailAddress = tableRow["EmailAddress"], TelephoneNumber = tableRow["TelephoneNumber"], Password = tableRow["Password"] }; await this.TestingContext.DockerHelper.GolfClubAdministratorClient.RegisterGolfClubAdministrator(registerClubAdministratorRequest, CancellationToken.None).ConfigureAwait(false); this.TestingContext.GolfClubAdministratorRequests.Add(tableRow["GolfClubNumber"], registerClubAdministratorRequest); } }
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); } }
public void GivenTheFollowingGolfClubAdministratorHasBeenRegistered(Table table) { TableRow tableRow = table.Rows.Single(); RegisterClubAdministratorRequest registerClubAdministratorRequest = new RegisterClubAdministratorRequest { ConfirmPassword = tableRow["ConfirmPassword"], FamilyName = tableRow["FamilyName"], GivenName = tableRow["GivenName"], MiddleName = tableRow["MiddleName"], EmailAddress = tableRow["EmailAddress"], TelephoneNumber = tableRow["TelephoneNumber"], Password = tableRow["Password"] }; this.TestingContext.RegisterClubAdministratorRequest = registerClubAdministratorRequest; this.TestingContext.GolfClubAdministratorRequests.Add(tableRow["GolfClubNumber"], registerClubAdministratorRequest); Should.NotThrow(async() => { await this.TestingContext.DockerHelper.GolfClubAdministratorClient.RegisterGolfClubAdministrator(this.TestingContext.RegisterClubAdministratorRequest, CancellationToken.None).ConfigureAwait(false); }); }
/// <summary> /// Registers the golf club administrator. /// </summary> /// <param name="registerClubAdministratorRequest">The register club administrator request.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public async Task RegisterGolfClubAdministrator(RegisterClubAdministratorRequest registerClubAdministratorRequest, CancellationToken cancellationToken) { await this.GolfClubClient.RegisterGolfClubAdministrator(registerClubAdministratorRequest, cancellationToken); }
/// <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 }); } }