public void SetsModelProperty_IsUrlConfirmation_ToTrue_WhenMethodArgIsNotNullOrWhiteSpace() { var confirmation = new EmailConfirmation(EmailConfirmationIntent.ResetPassword) { SecretCode = "very secret", }; const string secretCode = "not as secret"; var queryProcessor = new Mock <IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(confirmation.Token)))) .Returns(confirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); var result = controller.Get(confirmation.Token, secretCode); result.ShouldNotBeNull(); result.ShouldImplement <ViewResultBase>(); var viewResultBase = (ViewResultBase)result; viewResultBase.Model.ShouldNotBeNull(); viewResultBase.Model.ShouldBeType <ConfirmEmailForm>(); var model = (ConfirmEmailForm)viewResultBase.Model; model.SecretCode.ShouldEqual(secretCode); model.SecretCode.ShouldNotEqual(confirmation.SecretCode); model.IsUrlConfirmation.ShouldBeTrue(); }
public void SetsNoResult_WhenTokenMatchesEntity_Unexpired_Redeemed_Unretired_WithCorrectTicketAndIntent() { const string paramName = "some value"; const EmailConfirmationIntent intent = EmailConfirmationIntent.CreatePassword; const string ticket = "ticket value"; var confirmation = new EmailConfirmation(intent) { ExpiresOnUtc = DateTime.UtcNow.AddHours(1), RedeemedOnUtc = DateTime.UtcNow.AddSeconds(-5), Ticket = ticket, }; var entities = new Mock <IQueryEntities>(MockBehavior.Strict).Initialize(); entities.Setup(m => m.Query <EmailConfirmation>()) .Returns(new[] { confirmation }.AsQueryable); var attribute = new ValidateRedeemTicketAttribute(paramName, intent) { Entities = entities.Object, }; var controller = new ConfirmEmailController(null); controller.TempData.EmailConfirmationTicket(ticket); var filterContext = CreateFilterContext(paramName, confirmation.Token, controller); attribute.OnActionExecuting(filterContext); filterContext.Result.ShouldBeNull(); controller.TempData.EmailConfirmationTicket().ShouldEqual(ticket); }
public void SetsResult_ToConfirmEmailRedirect_WhenToken_MatchesUnredeemedEntity() { const string paramName = "some value"; const EmailConfirmationIntent intent = EmailConfirmationIntent.ResetPassword; var confirmation = new EmailConfirmation(intent) { ExpiresOnUtc = DateTime.UtcNow.AddHours(1), }; var entities = new Mock <IQueryEntities>(MockBehavior.Strict).Initialize(); entities.Setup(m => m.Query <EmailConfirmation>()) .Returns(new[] { confirmation }.AsQueryable); var attribute = new ValidateRedeemTicketAttribute(paramName, intent) { Entities = entities.Object, }; var controller = new ConfirmEmailController(null); var filterContext = CreateFilterContext(paramName, confirmation.Token, controller); attribute.OnActionExecuting(filterContext); filterContext.Result.ShouldNotBeNull(); filterContext.Result.ShouldBeType <RedirectToRouteResult>(); var routeResult = (RedirectToRouteResult)filterContext.Result; routeResult.Permanent.ShouldBeFalse(); routeResult.RouteValues["area"].ShouldEqual(MVC.Identity.Name); routeResult.RouteValues["controller"].ShouldEqual(MVC.Identity.ConfirmEmail.Name); routeResult.RouteValues["action"].ShouldEqual(MVC.Identity.ConfirmEmail.ActionNames.Get); routeResult.RouteValues["token"].ShouldEqual(confirmation.Token); }
public void ReturnsRedirect_ToCreatePassword_WhenIntentMatches() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.CreatePassword, SecretCode = "secret", }; var commandHandler = new Mock <IHandleCommands <RedeemEmailConfirmationCommand> >(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); var result = controller.Post(form); result.ShouldNotBeNull(); result.ShouldBeType <RedirectToRouteResult>(); var routeResult = (RedirectToRouteResult)result; routeResult.Permanent.ShouldBeFalse(); routeResult.RouteValues["area"].ShouldEqual(MVC.Identity.Name); routeResult.RouteValues["controller"].ShouldEqual(MVC.Identity.CreatePassword.Name); routeResult.RouteValues["action"].ShouldEqual(MVC.Identity.CreatePassword.ActionNames.Get); routeResult.RouteValues["token"].ShouldEqual(form.Token); }
public void ReturnsView_WhenModelState_IsInvalid() { var form = new ConfirmEmailForm { SecretCode = "wrong", }; var services = new ConfirmEmailServices(null, null); var controller = new ConfirmEmailController(services); controller.ModelState.AddModelError("error", String.Empty); var result = controller.Post(form); result.ShouldNotBeNull(); result.ShouldBeType <ViewResult>(); var viewResult = (ViewResult)result; viewResult.Model.ShouldNotBeNull(); viewResult.Model.ShouldBeType <ConfirmEmailForm>(); var model = (ConfirmEmailForm)viewResult.Model; model.ShouldEqual(form); model.Intent.ShouldEqual(form.Intent); model.SecretCode.ShouldEqual(form.SecretCode); }
public void Returns404_WhenModel_IsNull() { var services = new ConfirmEmailServices(null, null); var controller = new ConfirmEmailController(services); var result = controller.Post(null); result.ShouldNotBeNull(); result.ShouldBeType <HttpNotFoundResult>(); }
public void ReturnsTrue_WhenModelStateIsValid() { var model = new ConfirmEmailForm(); var controller = new ConfirmEmailController(null); var result = controller.ValidateSecretCode(model); result.ShouldNotBeNull(); result.ShouldBeType <JsonResult>(); result.JsonRequestBehavior.ShouldEqual(JsonRequestBehavior.DenyGet); result.Data.ShouldEqual(true); }
public void ReturnsRouteValues_ForCreatePasswordIntent() { var token = Guid.NewGuid(); const EmailConfirmationIntent intent = EmailConfirmationIntent.CreatePassword; var result = ConfirmEmailController.GetRedeemedRouteValues(token, intent); result.ShouldNotBeNull(); result["area"].ShouldEqual(MVC.Identity.Name); result["controller"].ShouldEqual(MVC.Identity.CreatePassword.Name); result["action"].ShouldEqual(MVC.Identity.CreatePassword.ActionNames.Get); result["token"].ShouldEqual(token); }
public void ReturnsView_WhenConfirmation_IsFound() { var confirmation = new EmailConfirmation(EmailConfirmationIntent.CreatePassword); var queryProcessor = new Mock <IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(confirmation.Token)))) .Returns(confirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); var result = controller.Get(confirmation.Token, null); result.ShouldNotBeNull(); result.ShouldBeType <ViewResult>(); }
public void ReturnsErrorMessage_WhenModelStateIsInvalid_ForValueProperty() { const string errorMessage = "Here is your error message."; var model = new ConfirmEmailForm(); var controller = new ConfirmEmailController(null); controller.ModelState.AddModelError(ConfirmEmailForm.SecretCodePropertyName, errorMessage); var result = controller.ValidateSecretCode(model); result.ShouldNotBeNull(); result.ShouldBeType <JsonResult>(); result.JsonRequestBehavior.ShouldEqual(JsonRequestBehavior.DenyGet); result.Data.ShouldEqual(errorMessage); }
public void Returns404_WhenConfirmation_CannotBeFound() { var token = Guid.NewGuid(); var queryProcessor = new Mock <IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(token)))) .Returns(null as EmailConfirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); var result = controller.Get(token, null); result.ShouldNotBeNull(); result.ShouldBeType <HttpNotFoundResult>(); }
public void ExecutesQuery_ForConfirmation() { var token = Guid.NewGuid(); var queryProcessor = new Mock <IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(token)))) .Returns(null as EmailConfirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); controller.Get(token, null); queryProcessor.Verify(m => m.Execute( It.Is(ConfirmationQueryBasedOn(token))), Times.Once()); }
public void ExecutesCommand_WhenAction_IsValid() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.ResetPassword, SecretCode = "secret", }; var commandHandler = new Mock <IHandleCommands <RedeemEmailConfirmationCommand> >(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); controller.Post(form); commandHandler.Verify(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form))), Times.Once()); }
public void SetsResult_ToPartialCrashDenaial_WhenIntent_ConflictsWithEntity() { const string paramName = "some value"; const EmailConfirmationIntent intent = EmailConfirmationIntent.ResetPassword; const string ticket = "ticket value"; var confirmation = new EmailConfirmation(EmailConfirmationIntent.CreatePassword) { ExpiresOnUtc = DateTime.UtcNow.AddHours(1), RedeemedOnUtc = DateTime.UtcNow.AddSeconds(-5), Ticket = ticket, }; var entities = new Mock <IQueryEntities>(MockBehavior.Strict).Initialize(); entities.Setup(m => m.Query <EmailConfirmation>()) .Returns(new[] { confirmation }.AsQueryable); var attribute = new ValidateRedeemTicketAttribute(paramName, intent) { Entities = entities.Object, }; var controller = new ConfirmEmailController(null); controller.TempData.EmailConfirmationTicket(ticket); var filterContext = CreateFilterContext(paramName, confirmation.Token, controller); attribute.OnActionExecuting(filterContext); filterContext.Result.ShouldNotBeNull(); filterContext.Result.ShouldBeType <PartialViewResult>(); var partialView = (PartialViewResult)filterContext.Result; partialView.ViewName.ShouldEqual(MVC.Identity.ConfirmEmail.Views._denied_all); partialView.Model.ShouldNotBeNull(); partialView.Model.ShouldBeType <ConfirmDeniedModel>(); var model = (ConfirmDeniedModel)partialView.Model; model.Reason.ShouldEqual(ConfirmDeniedBecause.OtherCrash); model.Intent.ShouldEqual(confirmation.Intent); }
public void FlashesSuccessMessage_ForCreatePassword_WhenIntentMatches() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.CreatePassword, SecretCode = "secret", }; var commandHandler = new Mock <IHandleCommands <RedeemEmailConfirmationCommand> >(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); controller.Post(form); controller.TempData.ShouldNotBeNull(); var message = controller.TempData.FeedbackMessage(); message.ShouldNotBeNull(); message.ShouldEqual(ConfirmEmailController.SuccessMessageForIntent [EmailConfirmationIntent.CreatePassword]); }
public void SetsEmailConfirmationTicket_InTempData_UsingCommandValue() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.ResetPassword, SecretCode = "secret", }; var commandHandler = new Mock <IHandleCommands <RedeemEmailConfirmationCommand> >(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))) .Callback((RedeemEmailConfirmationCommand command) => command.Ticket = TwoFiftySixLengthString1); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); controller.Post(form); controller.TempData.ShouldNotBeNull(); var ticket = controller.TempData.EmailConfirmationTicket(false); ticket.ShouldNotBeNull(); ticket.ShouldEqual(TwoFiftySixLengthString1); }
public void SetsResult_ToConfirmEmailRedirect_WhenTicket_ConflictsWithController() { const string paramName = "some value"; const EmailConfirmationIntent intent = EmailConfirmationIntent.CreatePassword; const string ticket = "ticket value"; var confirmation = new EmailConfirmation(intent) { ExpiresOnUtc = DateTime.UtcNow.AddHours(1), RedeemedOnUtc = DateTime.UtcNow.AddSeconds(-5), Ticket = ticket, }; var entities = new Mock<IQueryEntities>(MockBehavior.Strict).Initialize(); entities.Setup(m => m.Query<EmailConfirmation>()) .Returns(new[] { confirmation }.AsQueryable); var attribute = new ValidateRedeemTicketAttribute(paramName, intent) { Entities = entities.Object, }; var controller = new ConfirmEmailController(null); controller.TempData.EmailConfirmationTicket("a different ticket value"); var filterContext = CreateFilterContext(paramName, confirmation.Token, controller); attribute.OnActionExecuting(filterContext); filterContext.Result.ShouldNotBeNull(); filterContext.Result.ShouldBeType<RedirectToRouteResult>(); var routeResult = (RedirectToRouteResult)filterContext.Result; routeResult.Permanent.ShouldBeFalse(); routeResult.RouteValues["area"].ShouldEqual(MVC.Identity.Name); routeResult.RouteValues["controller"].ShouldEqual(MVC.Identity.ConfirmEmail.Name); routeResult.RouteValues["action"].ShouldEqual(MVC.Identity.ConfirmEmail.ActionNames.Get); routeResult.RouteValues["token"].ShouldEqual(confirmation.Token); }
public void SetsResult_ToPartialCrashDenaial_WhenIntent_ConflictsWithEntity() { const string paramName = "some value"; const EmailConfirmationIntent intent = EmailConfirmationIntent.ResetPassword; const string ticket = "ticket value"; var confirmation = new EmailConfirmation(EmailConfirmationIntent.CreatePassword) { ExpiresOnUtc = DateTime.UtcNow.AddHours(1), RedeemedOnUtc = DateTime.UtcNow.AddSeconds(-5), Ticket = ticket, }; var entities = new Mock<IQueryEntities>(MockBehavior.Strict).Initialize(); entities.Setup(m => m.Query<EmailConfirmation>()) .Returns(new[] { confirmation }.AsQueryable); var attribute = new ValidateRedeemTicketAttribute(paramName, intent) { Entities = entities.Object, }; var controller = new ConfirmEmailController(null); controller.TempData.EmailConfirmationTicket(ticket); var filterContext = CreateFilterContext(paramName, confirmation.Token, controller); attribute.OnActionExecuting(filterContext); filterContext.Result.ShouldNotBeNull(); filterContext.Result.ShouldBeType<PartialViewResult>(); var partialView = (PartialViewResult)filterContext.Result; partialView.ViewName.ShouldEqual(MVC.Identity.ConfirmEmail.Views._denied_all); partialView.Model.ShouldNotBeNull(); partialView.Model.ShouldBeType<ConfirmDeniedModel>(); var model = (ConfirmDeniedModel)partialView.Model; model.Reason.ShouldEqual(ConfirmDeniedBecause.OtherCrash); model.Intent.ShouldEqual(confirmation.Intent); }
public void ReturnsView_WhenModelState_IsInvalid() { var form = new ConfirmEmailForm { SecretCode = "wrong", }; var services = new ConfirmEmailServices(null, null); var controller = new ConfirmEmailController(services); controller.ModelState.AddModelError("error", String.Empty); var result = controller.Post(form); result.ShouldNotBeNull(); result.ShouldBeType<ViewResult>(); var viewResult = (ViewResult)result; viewResult.Model.ShouldNotBeNull(); viewResult.Model.ShouldBeType<ConfirmEmailForm>(); var model = (ConfirmEmailForm)viewResult.Model; model.ShouldEqual(form); model.Intent.ShouldEqual(form.Intent); model.SecretCode.ShouldEqual(form.SecretCode); }
public void ExecutesCommand_WhenAction_IsValid() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.ResetPassword, SecretCode = "secret", }; var commandHandler = new Mock<IHandleCommands<RedeemEmailConfirmationCommand>>(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); controller.Post(form); commandHandler.Verify(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form))), Times.Once()); }
public void SetsEmailConfirmationTicket_InTempData_UsingCommandValue() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.ResetPassword, SecretCode = "secret", }; var commandHandler = new Mock<IHandleCommands<RedeemEmailConfirmationCommand>>(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))) .Callback((RedeemEmailConfirmationCommand command) => command.Ticket = TwoFiftySixLengthString1); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); controller.Post(form); controller.TempData.ShouldNotBeNull(); var ticket = controller.TempData.EmailConfirmationTicket(false); ticket.ShouldNotBeNull(); ticket.ShouldEqual(TwoFiftySixLengthString1); }
public void FlashesSuccessMessage_ForCreatePassword_WhenIntentMatches() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.CreatePassword, SecretCode = "secret", }; var commandHandler = new Mock<IHandleCommands<RedeemEmailConfirmationCommand>>(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); controller.Post(form); controller.TempData.ShouldNotBeNull(); var message = controller.TempData.FeedbackMessage(); message.ShouldNotBeNull(); message.ShouldEqual(ConfirmEmailController.SuccessMessageForIntent [EmailConfirmationIntent.CreatePassword]); }
public void Extends_BaseController() { var controller = new ConfirmEmailController(null); controller.ShouldImplement <BaseController>(); }
public void ReturnsTrue_WhenModelStateIsValid() { var model = new ConfirmEmailForm(); var controller = new ConfirmEmailController(null); var result = controller.ValidateSecretCode(model); result.ShouldNotBeNull(); result.ShouldBeType<JsonResult>(); result.JsonRequestBehavior.ShouldEqual(JsonRequestBehavior.DenyGet); result.Data.ShouldEqual(true); }
public void ReturnsErrorMessage_WhenModelStateIsInvalid_ForValueProperty() { const string errorMessage = "Here is your error message."; var model = new ConfirmEmailForm(); var controller = new ConfirmEmailController(null); controller.ModelState.AddModelError(ConfirmEmailForm.SecretCodePropertyName, errorMessage); var result = controller.ValidateSecretCode(model); result.ShouldNotBeNull(); result.ShouldBeType<JsonResult>(); result.JsonRequestBehavior.ShouldEqual(JsonRequestBehavior.DenyGet); result.Data.ShouldEqual(errorMessage); }
public void Returns404_WhenModel_IsNull() { var services = new ConfirmEmailServices(null, null); var controller = new ConfirmEmailController(services); var result = controller.Post(null); result.ShouldNotBeNull(); result.ShouldBeType<HttpNotFoundResult>(); }
public void ExecutesQuery_ForConfirmation() { var token = Guid.NewGuid(); var queryProcessor = new Mock<IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(token)))) .Returns(null as EmailConfirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); controller.Get(token, null); queryProcessor.Verify(m => m.Execute( It.Is(ConfirmationQueryBasedOn(token))), Times.Once()); }
public void SetsNoResult_WhenTokenMatchesEntity_Unexpired_Redeemed_Unretired_WithCorrectTicketAndIntent() { const string paramName = "some value"; const EmailConfirmationIntent intent = EmailConfirmationIntent.CreatePassword; const string ticket = "ticket value"; var confirmation = new EmailConfirmation(intent) { ExpiresOnUtc = DateTime.UtcNow.AddHours(1), RedeemedOnUtc = DateTime.UtcNow.AddSeconds(-5), Ticket = ticket, }; var entities = new Mock<IQueryEntities>(MockBehavior.Strict).Initialize(); entities.Setup(m => m.Query<EmailConfirmation>()) .Returns(new[] { confirmation }.AsQueryable); var attribute = new ValidateRedeemTicketAttribute(paramName, intent) { Entities = entities.Object, }; var controller = new ConfirmEmailController(null); controller.TempData.EmailConfirmationTicket(ticket); var filterContext = CreateFilterContext(paramName, confirmation.Token, controller); attribute.OnActionExecuting(filterContext); filterContext.Result.ShouldBeNull(); controller.TempData.EmailConfirmationTicket().ShouldEqual(ticket); }
public void ReturnsRedirect_ToCreatePassword_WhenIntentMatches() { var form = new ConfirmEmailForm { Token = Guid.NewGuid(), Intent = EmailConfirmationIntent.CreatePassword, SecretCode = "secret", }; var commandHandler = new Mock<IHandleCommands<RedeemEmailConfirmationCommand>>(MockBehavior.Strict); commandHandler.Setup(m => m.Handle(It.Is(ConfirmationCommandBasedOn(form)))); var services = new ConfirmEmailServices(null, commandHandler.Object); var controller = new ConfirmEmailController(services); var result = controller.Post(form); result.ShouldNotBeNull(); result.ShouldBeType<RedirectToRouteResult>(); var routeResult = (RedirectToRouteResult)result; routeResult.Permanent.ShouldBeFalse(); routeResult.RouteValues["area"].ShouldEqual(MVC.Identity.Name); routeResult.RouteValues["controller"].ShouldEqual(MVC.Identity.CreatePassword.Name); routeResult.RouteValues["action"].ShouldEqual(MVC.Identity.CreatePassword.ActionNames.Get); routeResult.RouteValues["token"].ShouldEqual(form.Token); }
public void Extends_BaseController() { var controller = new ConfirmEmailController(null); controller.ShouldImplement<BaseController>(); }
public void Returns404_WhenConfirmation_CannotBeFound() { var token = Guid.NewGuid(); var queryProcessor = new Mock<IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(token)))) .Returns(null as EmailConfirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); var result = controller.Get(token, null); result.ShouldNotBeNull(); result.ShouldBeType<HttpNotFoundResult>(); }
public void ReturnsView_WhenConfirmation_IsFound() { var confirmation = new EmailConfirmation(EmailConfirmationIntent.CreatePassword); var queryProcessor = new Mock<IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(confirmation.Token)))) .Returns(confirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); var result = controller.Get(confirmation.Token, null); result.ShouldNotBeNull(); result.ShouldBeType<ViewResult>(); }
public void SetsModelProperty_IsUrlConfirmation_ToTrue_WhenMethodArgIsNotNullOrWhiteSpace() { var confirmation = new EmailConfirmation(EmailConfirmationIntent.ResetPassword) { SecretCode = "very secret", }; const string secretCode = "not as secret"; var queryProcessor = new Mock<IProcessQueries>(MockBehavior.Strict); queryProcessor.Setup(m => m.Execute(It.Is(ConfirmationQueryBasedOn(confirmation.Token)))) .Returns(confirmation); var services = new ConfirmEmailServices(queryProcessor.Object, null); var controller = new ConfirmEmailController(services); var result = controller.Get(confirmation.Token, secretCode); result.ShouldNotBeNull(); result.ShouldImplement<ViewResultBase>(); var viewResultBase = (ViewResultBase)result; viewResultBase.Model.ShouldNotBeNull(); viewResultBase.Model.ShouldBeType<ConfirmEmailForm>(); var model = (ConfirmEmailForm)viewResultBase.Model; model.SecretCode.ShouldEqual(secretCode); model.SecretCode.ShouldNotEqual(confirmation.SecretCode); model.IsUrlConfirmation.ShouldBeTrue(); }