public void Then_mediator_is_not_called() { _controller.Post(new CreatePasswordViewModel() { InvitationId = _invitationId, Password = "******", ConfirmPassword = "******" }).Wait(); _mediator.DidNotReceiveWithAnyArgs().Send(Arg.Any <CreatePasswordRequest>()); }
public void Then_ViewResult_is_returned() { var mediator = Substitute.For <IMediator>(); mediator.Send(Arg.Any <CreatePasswordRequest>()).Returns(new CreatePasswordResponse() { PasswordValid = false }); mediator.Send(Arg.Any <GetInvitationByIdRequest>()).Returns(new Invitation()); var controller = new CreatePasswordController(mediator); var invitationId = Guid.NewGuid(); var result = controller.Post(new CreatePasswordViewModel() { InvitationId = invitationId, Password = "******", ConfirmPassword = "******" }).Result; result.Should().BeOfType <ViewResult>(); ((ViewResult)result).ViewName.Should().Be("CreatePassword"); ((CreatePasswordViewModel)((ViewResult)result).Model).Password.Should().Be("Pa55word"); ((CreatePasswordViewModel)((ViewResult)result).Model).ConfirmPassword.Should().Be("Pa55word"); controller.ModelState.Count.Should().Be(1); controller.ModelState.ValidationState.Should().Be(ModelValidationState.Invalid); controller.ModelState.First().Key.Should().Be("Password"); controller.ModelState.First().Value.Errors.First().ErrorMessage.Should().Be("Password does not meet minimum complexity requirements"); }
public async Task Then_View_is_returned_with_identical_ViewModel(string password, string confirmPassword) { var createPasswordViewModel = new CreatePasswordViewModel() { Password = password, ConfirmPassword = confirmPassword }; var result = await _controller.Post(createPasswordViewModel); result.Should().BeOfType <ViewResult>(); ((ViewResult)result).ViewName.Should().Be("CreatePassword"); ((ViewResult)result).Model.Should().BeOfType <CreatePasswordViewModel>(); ((CreatePasswordViewModel)((ViewResult)result).Model).Should().BeSameAs(createPasswordViewModel); }
public void Then_BadRequest_Is_Returned() { var mediator = Substitute.For <IMediator>(); mediator.Send(Arg.Any <GetInvitationByIdRequest>()).Returns(default(Invitation)); var controller = new CreatePasswordController(mediator); var result = controller.Post(new CreatePasswordViewModel() { InvitationId = Guid.NewGuid() }).Result; result.Should().BeOfType <BadRequestObjectResult>(); }
public void Then_mediator_is_called_with_correct_request() { var mediator = Substitute.For <IMediator>(); mediator.Send(Arg.Any <CreatePasswordRequest>()).Returns(new CreatePasswordResponse() { PasswordValid = true }); mediator.Send(Arg.Any <GetInvitationByIdRequest>()).Returns(new Invitation()); var controller = new CreatePasswordController(mediator); var invitationId = Guid.NewGuid(); controller.Post(new CreatePasswordViewModel() { InvitationId = invitationId, Password = "******", ConfirmPassword = "******" }).Wait(); mediator.Received().Send(Arg.Is <CreatePasswordRequest>(r => r.InvitationId == invitationId && r.Password == "Pa55word")); }
public void Then_RedirectToActionResult_is_returned() { var mediator = Substitute.For <IMediator>(); mediator.Send(Arg.Any <CreatePasswordRequest>()).Returns(new CreatePasswordResponse() { PasswordValid = true }); mediator.Send(Arg.Any <GetInvitationByIdRequest>()).Returns(new Invitation()); var controller = new CreatePasswordController(mediator); var invitationId = Guid.NewGuid(); var result = controller.Post(new CreatePasswordViewModel() { InvitationId = invitationId, Password = "******", ConfirmPassword = "******" }).Result; result.Should().BeOfType <RedirectToActionResult>(); ((RedirectToActionResult)result).ActionName.Should().Be("Get"); ((RedirectToActionResult)result).ControllerName.Should().Be("SignUpComplete"); ((RedirectToActionResult)result).RouteValues["id"].Should().Be(invitationId); }