public void cant_login_if_disabled() { var disabledAgency = new AgencyBuilder().WithRole(RoleNames.disabled).Build(); agencyService .Expect(s => s.Authenticate(It.IsAny<string>(),It.IsAny<string>())) .Returns(disabledAgency) .Verifiable(); var result = (ViewResult)loginController.Authenticate(String.Empty, String.Empty, false); AssertTempDataError(result.TempData, "Authentication failed."); Assert.AreEqual("Index", result.ViewName); agencyService.Verify(); }
public void Edit() { int agencyId = 58; var agency = new AgencyBuilder().WithId(agencyId).Build(); var agencyRepoMock = new Mock<IAgencyRepository>(); var agencyServiceMock = new Mock<IAgencyService>(); agencyServiceMock.Expect(service => service.CurrentAgency).Returns(agency); var controller = new ProfileController(agencyServiceMock.Object, null, null); ViewResult result = (ViewResult)controller.Edit(); Assert.AreEqual("Profile", result.ViewName); ProfileViewModel data = (ProfileViewModel)result.ViewData.Model; Assert.AreEqual("LJ Hooker", data.Name); }
public void can_disable_an_agency() { const int agencyId = 10; var agency = new AgencyBuilder().WithId(agencyId).WithRole(RoleNames.agency).Build(); agencyRepo .Expect(ar => ar.FindNoAuth(agencyId)) .Returns(agency) .Verifiable(); saver.Expect(s => s.SaveAll()).Verifiable(); var result = (RedirectToRouteResult)adminController.DisableAgency(agencyId); saver.Verify(); agencyRepo.Verify(); Assert.AreEqual(RoleNames.disabled, agency.Role); AssertRedirectToRoute(result, "Agencies"); }
protected void EstablishAgencyContext() { var agency = new AgencyBuilder().Build(); System.Threading.Thread.CurrentPrincipal = agency; agencyContext = new AgencyContext(); }
public void when_password_is_more_than_50_characters_validation_fails() { var a = new AgencyBuilder().WithPassword(GetCharacters(51)).Build(); AssertInvalidWithAtLeastOneErrorOnProperty(a, "Password"); }
public void when_password_is_empty_validation_fails() { var a = new AgencyBuilder().WithPassword(String.Empty).Build(); AssertInvalidWithAtLeastOneErrorOnProperty(a, "Password"); }
public void when_password_is_less_than_51_characters_validation_passes() { var a = new AgencyBuilder().WithPassword(GetCharacters(50)).Build(); AssertIsValid(a); }
public void when_name_is_empty_validation_passes() { var a = new AgencyBuilder().WithName(String.Empty).Build(); AssertIsValid(a); }
public void when_name_is_null_validation_fails() { var a = new AgencyBuilder().WithName(null).Build(); AssertInvalidWithAtLeastOneErrorOnProperty(a, "Name"); }
public void when_email_is_more_than_100_characters_validation_fails() { var a = new AgencyBuilder().WithEmail(GetCharacters(101)).Build(); Assert.IsFalse(a.IsValid); Assert.AreEqual(2, a.Errors.Count); }
public void when_email_is_null_validation_fails() { var a = new AgencyBuilder().WithEmail(null).Build(); Assert.IsFalse(a.IsValid); }
public void when_email_is_less_than_101_characters_validation_passes() { var a = new AgencyBuilder().Build(); AssertIsValid(a); }
public void when_email_is_empty_validation_fails() { var a = new AgencyBuilder().WithEmail(String.Empty).Build(); Assert.IsFalse(a.IsValid); }
public void when_email_invalid_then_validation_fails() { var a = new AgencyBuilder().WithEmail("abba@somedotcom").Build(); AssertInvalidWithAtLeastOneErrorOnProperty(a, "Email"); }
public void when_username_is_more_than_50_characters_validation_fails() { var a = new AgencyBuilder().WithUserName(GetCharacters(51)).Build(); AssertInvalidWithAtLeastOneErrorOnProperty(a, "UserName"); }
public void when_username_is_empty_validation_fails() { var a = new AgencyBuilder().WithUserName(String.Empty).Build(); AssertInvalidWithAtLeastOneErrorOnProperty(a, "UserName"); }