public void RegisteringUser_WhenGivenUsernameNotExists_AddsUser() { var dbContext = DbContextProvider.CreateMainDbForTests(MethodBase.GetCurrentMethod().Name); var aggregateRoot = new UserAggregateRoot(null, dbContext); const string alreadyAddedUserName = "******"; const string testedUserName = "******"; dbContext.Users.Add(new EFDAL.Entities.User() { FirstName = "aa", LastName = "bb", EmailAddress = "*****@*****.**", PasswordHash = "abcdefgh", Username = alreadyAddedUserName, }); dbContext.SaveChanges(); var userModel = new EditUserModel() { FirstName = "testFirstName", LastName = "testLastName", EmailAddress = "*****@*****.**", Password = "******", Username = testedUserName }; aggregateRoot.AddNew(userModel, new SHA256PasswordHasher()); Assert.AreEqual(2, dbContext.Users.Count()); Assert.IsNotNull(dbContext.Users.Single(x => x.Username == testedUserName)); }
public void RegisteringUser_WhenGivenUsernameExists_Fails() { var dbContext = DbContextProvider.CreateMainDbForTests(MethodBase.GetCurrentMethod().Name); var aggregateRoot = new UserAggregateRoot(null, dbContext); const string testedUserName = "******"; dbContext.Users.Add(new EFDAL.Entities.User() { FirstName = "aa", LastName = "bb", EmailAddress = "*****@*****.**", PasswordHash = "abcdefgh", Username = testedUserName, }); dbContext.SaveChanges(); var userModel = new EditUserModel() { FirstName = "testFirstName", LastName = "testLastName", EmailAddress = "*****@*****.**", Password = "******", Username = testedUserName }; Assert.ThrowsException <HavingFunBusinessValidationException>(() => aggregateRoot.AddNew(userModel, new SHA256PasswordHasher())); }
public void Add(AddInputDto input) { var user = new UserAggregateRoot(input.LoginName, input.NickName, input.Password); user.Validate(); _repository.Add(user); _repository.UnitOfWork.Commit(); }
public MenuController(UserAggregateRoot userAggregateRoot) { _userAggregateRoot = userAggregateRoot; }
public AccountController(UserAggregateRoot userAggregateRoot) { _userAggregateRoot = userAggregateRoot; }
public HomeController(UserAggregateRoot userAggregateRoot) { _userAggregateRoot = userAggregateRoot; }