public async Task ThenTheMediatorCommandIsCalledWithCorrectParameters() { //Arrange var model = ArrangeModel(); //Act await _employerAccountOrchestrator.CreateAccount(model, It.IsAny <HttpContextBase>()); //Assert _mediator.Verify(x => x.SendAsync(It.Is <CreateAccountCommand>( c => c.AccessToken.Equals(model.AccessToken) && c.OrganisationDateOfInception.Equals(model.OrganisationDateOfInception) && c.OrganisationName.Equals(model.OrganisationName) && c.OrganisationReferenceNumber.Equals(model.OrganisationReferenceNumber) && c.OrganisationAddress.Equals(model.OrganisationAddress) && c.OrganisationDateOfInception.Equals(model.OrganisationDateOfInception) && c.OrganisationStatus.Equals(model.OrganisationStatus) && c.PayeReference.Equals(model.PayeReference) && c.AccessToken.Equals(model.AccessToken) && c.RefreshToken.Equals(model.RefreshToken) && c.EmployerRefName.Equals(model.EmployerRefName) ))); }
public static void CreateDasAccount(UserViewModel userView, EmployerAccountOrchestrator orchestrator) { orchestrator.CreateAccount(new CreateAccountViewModel { UserId = userView.UserRef, AccessToken = Guid.NewGuid().ToString(), RefreshToken = Guid.NewGuid().ToString(), OrganisationDateOfInception = new DateTime(2016, 01, 01), PayeReference = $"{Guid.NewGuid().ToString().Substring(0, 3)}/{Guid.NewGuid().ToString().Substring(0, 7)}", OrganisationName = "Test Company", OrganisationReferenceNumber = "123456TGB" + Guid.NewGuid().ToString().Substring(0, 6), OrganisationAddress = "Address Line 1", OrganisationStatus = "active" }, new Mock <HttpContextBase>().Object).Wait(); }
public async Task <ActionResult> CreateAccount() { var enteredData = _employerAccountOrchestrator.GetCookieData(HttpContext); if (enteredData == null) { return(RedirectToAction("SelectEmployer", "EmployerAccount")); } var request = new CreateAccountViewModel { UserId = GetUserId(), OrganisationType = enteredData.OrganisationType, OrganisationReferenceNumber = enteredData.OrganisationReferenceNumber, OrganisationName = enteredData.OrganisationName, OrganisationAddress = enteredData.OrganisationRegisteredAddress, OrganisationDateOfInception = enteredData.OrganisationDateOfInception, PayeReference = enteredData.PayeReference, AccessToken = enteredData.AccessToken, RefreshToken = enteredData.RefreshToken, OrganisationStatus = string.IsNullOrWhiteSpace(enteredData.OrganisationStatus) ? null : enteredData.OrganisationStatus, EmployerRefName = enteredData.EmployerRefName, PublicSectorDataSource = enteredData.PublicSectorDataSource, Sector = enteredData.Sector }; var response = await _employerAccountOrchestrator.CreateAccount(request, HttpContext); if (response.Status == HttpStatusCode.BadRequest) { response.Status = HttpStatusCode.OK; response.FlashMessage = new FlashMessageViewModel { Headline = "There was a problem creating your account" }; return(RedirectToAction("summary")); } var flashmessage = new FlashMessageViewModel { Headline = "Account created", HiddenFlashMessageInformation = enteredData.OrganisationType.ToString(), Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashmessage); return(RedirectToAction("Index", "EmployerTeam", new { response.Data.EmployerAgreement.HashedAccountId })); }
public async Task <ActionResult> CreateAccount() { var enteredData = _employerAccountOrchestrator.GetCookieData(HttpContext); if (enteredData == null) { // N.B CHANGED THIS FROM SelectEmployer which went nowhere. _employerAccountOrchestrator.DeleteCookieData(HttpContext); return(RedirectToAction(ControllerConstants.SearchForOrganisationActionName, ControllerConstants.SearchOrganisationControllerName)); } var request = new CreateAccountViewModel { UserId = GetUserId(), OrganisationType = enteredData.OrganisationType, OrganisationReferenceNumber = enteredData.OrganisationReferenceNumber, OrganisationName = enteredData.OrganisationName, OrganisationAddress = enteredData.OrganisationRegisteredAddress, OrganisationDateOfInception = enteredData.OrganisationDateOfInception, PayeReference = enteredData.PayeReference, AccessToken = enteredData.AccessToken, RefreshToken = enteredData.RefreshToken, OrganisationStatus = string.IsNullOrWhiteSpace(enteredData.OrganisationStatus) ? null : enteredData.OrganisationStatus, EmployerRefName = enteredData.EmployerRefName, PublicSectorDataSource = enteredData.PublicSectorDataSource, Sector = enteredData.Sector }; var response = await _employerAccountOrchestrator.CreateAccount(request, HttpContext); if (response.Status == HttpStatusCode.BadRequest) { response.Status = HttpStatusCode.OK; response.FlashMessage = new FlashMessageViewModel { Headline = "There was a problem creating your account" }; return(RedirectToAction(ControllerConstants.SummaryActionName)); } return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerTeamActionName, new { response.Data.EmployerAgreement.HashedAccountId })); }