public void Reset_ResetsAccount() { Account account = context.Set <Account>().AsNoTracking().Single(); AccountResetView view = ObjectFactory.CreateAccountResetView(); hasher.HashPassword(view.NewPassword).Returns("Reset"); account.RecoveryTokenExpirationDate = null; account.RecoveryToken = null; account.Passhash = "Reset"; service.Reset(view); Account actual = context.Set <Account>().AsNoTracking().Single(); Account expected = account; Assert.Equal(expected.RecoveryTokenExpirationDate, actual.RecoveryTokenExpirationDate); Assert.Equal(expected.RecoveryToken, actual.RecoveryToken); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.IsLocked, actual.IsLocked); Assert.Equal(expected.Passhash, actual.Passhash); Assert.Equal(expected.Username, actual.Username); Assert.Equal(expected.RoleId, actual.RoleId); Assert.Equal(expected.Email, actual.Email); Assert.Equal(expected.Id, actual.Id); }
public void CanReset_CanNotResetAccountWithExpiredToken() { Account account = context.Set <Account>().Single(); account.RecoveryTokenExpirationDate = DateTime.Now.AddMinutes(-5); context.SaveChanges(); Assert.False(validator.CanReset(ObjectFactory.CreateAccountResetView())); }
public void SetUp() { validator = Substitute.For <IAccountValidator>(); service = Substitute.For <IAccountService>(); accountRecovery = ObjectFactory.CreateAccountRecoveryView(); accountReset = ObjectFactory.CreateAccountResetView(); accountLogin = ObjectFactory.CreateAccountLoginView(); account = new AccountView(); controller = Substitute.ForPartsOf <AuthController>(validator, service); controller.ControllerContext = new ControllerContext(); }
public void CanReset_ExpiredToken_ReturnsFalse() { account.RecoveryTokenExpirationDate = DateTime.Now.AddMinutes(-5); context.SaveChanges(); Boolean canReset = validator.CanReset(ObjectFactory.CreateAccountResetView()); Alert alert = validator.Alerts.Single(); Assert.False(canReset); Assert.Equal(0, alert.Timeout); Assert.Empty(validator.ModelState); Assert.Equal(AlertType.Danger, alert.Type); Assert.Equal(Validations.ExpiredToken, alert.Message); }
public void SetUp() { validator = Substitute.For <IAccountValidator>(); service = Substitute.For <IAccountService>(); accountRecovery = ObjectFactory.CreateAccountRecoveryView(); accountReset = ObjectFactory.CreateAccountResetView(); accountLogin = ObjectFactory.CreateAccountLoginView(); account = new AccountView(); controller = Substitute.ForPartsOf <AuthController>(service, validator); controller.Url = new UrlHelper(new HttpMock().HttpContext.Request.RequestContext); controller.ControllerContext = new ControllerContext(); }
public void CanReset_AddsErorrMessageThenCanNotResetAccountWithExpiredToken() { Account account = context.Set <Account>().Single(); account.RecoveryTokenExpirationDate = DateTime.Now.AddMinutes(-5); context.SaveChanges(); validator.CanReset(ObjectFactory.CreateAccountResetView()); String expected = Validations.RecoveryTokenExpired; String actual = validator.Alerts.Single().Message; Assert.AreEqual(expected, actual); }
public AuthControllerTests() { mail = Substitute.For <IMailClient>(); service = Substitute.For <IAccountService>(); validator = Substitute.For <IAccountValidator>(); controller = Substitute.ForPartsOf <AuthController>(validator, service, mail); controller.ControllerContext.HttpContext = Substitute.For <HttpContext>(); controller.TempData = Substitute.For <ITempDataDictionary>(); controller.ControllerContext.RouteData = new RouteData(); controller.Url = Substitute.For <IUrlHelper>(); accountRecovery = ObjectFactory.CreateAccountRecoveryView(); accountReset = ObjectFactory.CreateAccountResetView(); accountLogin = ObjectFactory.CreateAccountLoginView(); }
public void CanReset_AddsErorrMessageThenCanNotResetAccountWithExpiredToken() { Account account = context.Set <Account>().Single(); account.RecoveryTokenExpirationDate = DateTime.Now.AddMinutes(-5); context.SaveChanges(); validator.CanReset(ObjectFactory.CreateAccountResetView()); Alert actual = validator.Alerts.Single(); Assert.Equal(Validations.RecoveryTokenExpired, actual.Message); Assert.Equal(AlertType.Danger, actual.Type); Assert.Equal(0, actual.FadeoutAfter); }
public AuthControllerTests() { mailClient = Substitute.For <IMailClient>(); service = Substitute.For <IAccountService>(); validator = Substitute.For <IAccountValidator>(); controller = Substitute.ForPartsOf <AuthController>(validator, service, mailClient); HttpContextBase context = HttpContextFactory.CreateHttpContextBase(); controller.Url = new UrlHelper(context.Request.RequestContext); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = context; accountRecovery = ObjectFactory.CreateAccountRecoveryView(); accountReset = ObjectFactory.CreateAccountResetView(); accountLogin = ObjectFactory.CreateAccountLoginView(); }
public void Reset_ResetsAccount() { AccountResetView accountReset = ObjectFactory.CreateAccountResetView(); Account expected = context.Set <Account>().AsNoTracking().Single(); hasher.HashPassword(accountReset.NewPassword).Returns("Reset"); service.Reset(accountReset); Account actual = context.Set <Account>().Single(); expected.RecoveryTokenExpirationDate = null; expected.RecoveryToken = null; expected.Passhash = "Reset"; TestHelper.PropertyWiseEqual(expected, actual); }
public void CanReset_ValidAccount() { Assert.True(validator.CanReset(ObjectFactory.CreateAccountResetView())); Assert.Empty(validator.ModelState); Assert.Empty(validator.Alerts); }
public void CanReset_InvalidState_ReturnsFalse() { validator.ModelState.AddModelError("Test", "Test"); Assert.False(validator.CanReset(ObjectFactory.CreateAccountResetView())); }
public void CanReset_CanNotResetAccountWithInvalidModelState() { validator.ModelState.AddModelError("Test", "Test"); Assert.False(validator.CanReset(ObjectFactory.CreateAccountResetView())); }