public void FlashesNoChangesMessage_WhenCommand_ChangedState() { const string principalIdentityName = "*****@*****.**"; const int establishmentId = 8; const string jobTitles = "job titles"; const EmployeeOrStudentAffiliate employeeOrStudentAffiliation = EmployeeOrStudentAffiliate.StudentOnly; const string returnUrl = "http://www.site.tld"; var scenarioOptions = new ScenarioOptions { PrincipalIdentityName = principalIdentityName, }; var model = new UpdateAffiliationForm { JobTitles = jobTitles, EstablishmentId = establishmentId, EmployeeOrStudentAffiliation = employeeOrStudentAffiliation, IsClaimingFaculty = true, ReturnUrl = returnUrl, }; var controller = CreateController(scenarioOptions); scenarioOptions.MockCommandHandler.Setup(m => m.Handle( It.Is(CommandBasedOn(model, principalIdentityName)))); controller.Put(model); controller.TempData.ShouldNotBeNull(); var message = controller.TempData.FeedbackMessage(); message.ShouldNotBeNull(); message.ShouldEqual(UpdateAffiliationController.NoChangesMessage); }
public void ReturnsRedirect_ToModelReturnUrl_AfterCommandIsExecuted() { const string principalIdentityName = "*****@*****.**"; const int establishmentId = 8; const string jobTitles = "job titles"; const EmployeeOrStudentAffiliate employeeOrStudentAffiliation = EmployeeOrStudentAffiliate.StudentOnly; const string returnUrl = "http://www.site.tld"; var scenarioOptions = new ScenarioOptions { PrincipalIdentityName = principalIdentityName, }; var model = new UpdateAffiliationForm { JobTitles = jobTitles, EstablishmentId = establishmentId, EmployeeOrStudentAffiliation = employeeOrStudentAffiliation, IsClaimingStaff = true, ReturnUrl = returnUrl, }; var controller = CreateController(scenarioOptions); scenarioOptions.MockCommandHandler.Setup(m => m.Handle( It.Is(CommandBasedOn(model, principalIdentityName)))); var result = controller.Put(model); result.ShouldNotBeNull(); result.ShouldBeType <RedirectResult>(); var redirectResult = (RedirectResult)result; redirectResult.Url.ShouldEqual(model.ReturnUrl); redirectResult.Permanent.ShouldBeFalse(); }
public void ExecutesCommand_WhenAction_IsValid() { const string principalIdentityName = "*****@*****.**"; const int establishmentId = 8; const string jobTitles = "job titles"; const EmployeeOrStudentAffiliate employeeOrStudentAffiliation = EmployeeOrStudentAffiliate.StudentOnly; const string returnUrl = "http://www.site.tld"; var scenarioOptions = new ScenarioOptions { PrincipalIdentityName = principalIdentityName, }; var model = new UpdateAffiliationForm { JobTitles = jobTitles, EstablishmentId = establishmentId, EmployeeOrStudentAffiliation = employeeOrStudentAffiliation, IsClaimingInternationalOffice = true, ReturnUrl = returnUrl, }; var controller = CreateController(scenarioOptions); scenarioOptions.MockCommandHandler.Setup(m => m.Handle( It.Is(CommandBasedOn(model, principalIdentityName)))); controller.Put(model); scenarioOptions.MockCommandHandler.Verify(m => m.Handle(It.Is(CommandBasedOn(model, principalIdentityName))), Times.Once()); }