コード例 #1
0
ファイル: UsersTests.cs プロジェクト: chomiczkowy/HavingFun
        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));
        }
コード例 #2
0
ファイル: UsersTests.cs プロジェクト: chomiczkowy/HavingFun
        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()));
        }
コード例 #3
0
ファイル: UserAppService.cs プロジェクト: ousoft/Oyang
        public void Add(AddInputDto input)
        {
            var user = new UserAggregateRoot(input.LoginName, input.NickName, input.Password);

            user.Validate();
            _repository.Add(user);
            _repository.UnitOfWork.Commit();
        }
コード例 #4
0
 public MenuController(UserAggregateRoot userAggregateRoot)
 {
     _userAggregateRoot = userAggregateRoot;
 }
コード例 #5
0
 public AccountController(UserAggregateRoot userAggregateRoot)
 {
     _userAggregateRoot = userAggregateRoot;
 }
コード例 #6
0
 public HomeController(UserAggregateRoot userAggregateRoot)
 {
     _userAggregateRoot = userAggregateRoot;
 }