public void CanCreate_CanNotCreateWithAlreadyUsedEmail() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(); view.Id += "DifferentValue"; Assert.False(validator.CanCreate(view)); }
public void Create_RefreshesAuthorizationProvider() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(2); service.Create(view); Authorization.Provider.Received().Refresh(); }
public void CanCreate_CanNotCreateWithAlreadyTakenUsername() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(); view.Username = view.Username.ToLower(); view.Id += "DifferentValue"; Assert.False(validator.CanCreate(view)); }
public void Create_RefreshesAuthorization() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(2); view.RoleId = null; service.Create(view); authorizationProvider.Received().Refresh(); }
public void CanCreate_UsedUsername_ReturnsFalse() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(1); view.Username = account.Username.ToLower(); Boolean canCreate = validator.CanCreate(view); Assert.False(canCreate); Assert.Single(validator.ModelState); Assert.Equal(Validations.UniqueUsername, validator.ModelState["Username"].Errors.Single().ErrorMessage); }
public void CanCreate_UsedEmail_ReturnsFalse() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(1); view.Email = account.Email.ToUpper(); Boolean canCreate = validator.CanCreate(view); Assert.False(canCreate); Assert.Single(validator.ModelState); Assert.Equal(Validations.UniqueEmail, validator.ModelState["Email"].Errors.Single().ErrorMessage); }
public AccountsControllerTests() { validator = Substitute.For <IAccountValidator>(); service = Substitute.For <IAccountService>(); accountCreate = ObjectFactory.CreateAccountCreateView(); accountEdit = ObjectFactory.CreateAccountEditView(); account = ObjectFactory.CreateAccountView(); controller = Substitute.ForPartsOf <AccountsController>(validator, service); controller.ActionContext.RouteData = new RouteData(); }
public void Create_RefreshesAuthorization() { Authorization.Provider = Substitute.For <IAuthorizationProvider>(); AccountCreateView view = ObjectFactory.CreateAccountCreateView(1); view.RoleId = null; service.Create(view); Authorization.Provider.Received().Refresh(); }
public void CanCreate_AddsErrorMessageThenCanNotCreateWithAlreadyUsedEmail() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(); view.Id += "DifferentValue"; validator.CanCreate(view); String actual = validator.ModelState["Email"].Errors[0].ErrorMessage; String expected = Validations.EmailIsAlreadyUsed; Assert.Equal(expected, actual); }
public void CanCreate_AddsErorrMessageThenCanNotCreateWithAlreadyTakenUsername() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(); view.Username = view.Username.ToLower(); view.Id += "DifferentValue"; validator.CanCreate(view); String actual = validator.ModelState["Username"].Errors[0].ErrorMessage; String expected = Validations.UsernameIsAlreadyTaken; Assert.Equal(expected, actual); }
public AccountsControllerTests() { validator = Substitute.For <IAccountValidator>(); service = Substitute.For <IAccountService>(); accountCreate = ObjectFactory.CreateAccountCreateView(); accountEdit = ObjectFactory.CreateAccountEditView(); account = ObjectFactory.CreateAccountView(); controller = Substitute.ForPartsOf <AccountsController>(validator, service); controller.ControllerContext.HttpContext = Substitute.For <HttpContext>(); controller.TempData = Substitute.For <ITempDataDictionary>(); controller.ControllerContext.RouteData = new RouteData(); controller.Url = Substitute.For <IUrlHelper>(); }
public AccountsControllerTests() { validator = Substitute.For <IAccountValidator>(); service = Substitute.For <IAccountService>(); accountCreate = ObjectFactory.CreateAccountCreateView(); accountEdit = ObjectFactory.CreateAccountEditView(); account = ObjectFactory.CreateAccountView(); Authorization.Provider = Substitute.For <IAuthorizationProvider>(); controller = Substitute.ForPartsOf <AccountsController>(validator, service); controller.ControllerContext = new ControllerContext { RouteData = new RouteData() }; }
public void MapAccounts_MapsAccountCreateViewToAccount() { AccountCreateView expected = ObjectFactory.CreateAccountCreateView(); Account actual = Mapper.Map <Account>(expected); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.Username, actual.Username); Assert.Null(actual.RecoveryTokenExpirationDate); Assert.Equal(expected.RoleId, actual.RoleId); Assert.Equal(expected.Email, actual.Email); Assert.Equal(expected.Id, actual.Id); Assert.Null(actual.RecoveryToken); Assert.False(actual.IsLocked); Assert.Null(actual.Passhash); Assert.Null(actual.Role); }
public void Create_Account() { AccountCreateView view = ObjectFactory.CreateAccountCreateView(1); view.Email = view.Email.ToUpper(); view.RoleId = account.RoleId; service.Create(view); Account actual = context.Set <Account>().AsNoTracking().Single(model => model.Id != account.Id); AccountCreateView expected = view; Assert.Equal(hasher.HashPassword(expected.Password), actual.Passhash); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.Email.ToLower(), actual.Email); Assert.Equal(expected.Username, actual.Username); Assert.Null(actual.RecoveryTokenExpirationDate); Assert.Equal(expected.RoleId, actual.RoleId); Assert.Null(actual.RecoveryToken); Assert.False(actual.IsLocked); }
public void CanCreate_ValidAccount() { Assert.True(validator.CanCreate(ObjectFactory.CreateAccountCreateView(1))); Assert.Empty(validator.ModelState); Assert.Empty(validator.Alerts); }
public void CanCreate_InvalidState_ReturnsFalse() { validator.ModelState.AddModelError("Test", "Test"); Assert.False(validator.CanCreate(ObjectFactory.CreateAccountCreateView(1))); }
public void CanCreate_ValidAccount() { Assert.True(validator.CanCreate(ObjectFactory.CreateAccountCreateView(2))); }
public void CanCreate_CanNotCreateWithInvalidModelState() { validator.ModelState.AddModelError("Key", "Error"); Assert.False(validator.CanCreate(ObjectFactory.CreateAccountCreateView())); }