예제 #1
0
        public void AddUser_ShouldWork()
        {
            // Arrange
            int expected = TestDB.GetUserTable().Count + 1;

            // Act
            bool validCall = container.AddUser(user);
            int  result    = container.Users.Count;

            // Assert
            Assert.Equal(expected, result);
            Assert.True(validCall);
        }
예제 #2
0
        public void AddUser_ShouldWork()
        {
            // Arrange
            int expected = 1;


            // Act
            bool validCall = container.AddUser(user);
            int  result    = container.Users.Count;

            // Assert
            Assert.Equal(expected, result);
            Assert.True(validCall);
            Assert.Equal(user, container.Users[0]);
        }
예제 #3
0
        public void AddUser_ShouldWork()
        {
            // Arrange
            int expected = 4;

            container = new UserContainer(repo.CreateUserContainerDal(), repo.CreateUserDAL(), repo.CreateBetDAL());

            User toAdd = new User("Pablo", null, null)
            {
                Id = 13,
            };

            bool validCall;

            // Act
            using (TransactionScope scope = new TransactionScope())
            {
                validCall = container.AddUser(toAdd);


                // Assert
                Assert.True(validCall);
                Assert.Equal(expected, container.Users.Count);
            }
        }
 public User AddUser(User user)
 {
     try
     {
         return(UserContainer.AddUser(user));
     }
     catch (Exception ex)
     {
         //todo throw custom ex;
         throw ex;
     }
 }
예제 #5
0
        public ActionResult Create(UserModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (container.AddUser(CreateUser(model)))
                {
                    return(RedirectToAction(nameof(Index)));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
예제 #6
0
 public ActionResult RegisterUser(RegisterViewModel user)
 {
     //try add User voegt de waardes toe aan de database
     if (ModelState.IsValid)
     {
         try
         {
             userContainer.AddUser(user);
             ViewBag.SuccesOrNot = "You succesfully created an account!";
             return(RedirectToAction("Login", "Account"));
         }
         catch
         {
             ViewBag.SuccesOrNot = "Your account could not be created!";
             return(RedirectToAction("Register", "Account"));
         }
     }
     ViewBag.SuccesOrNot = "Please enter all required fields!";
     return(RedirectToAction("Register", "Account"));
 }