// This unit test is designed to verify the AddFoodItem method is adding a new row on the user db table
        public void AddFoodItem_ShouldAddNewRowItem()
        {
            //ARRANGE
            FoodSqlDAO foodItemDAO = new FoodSqlDAO("Server=.\\SQLEXPRESS;Database=DemoDB;Trusted_Connection=True;");
            UserSqlDAO userDAO     = new UserSqlDAO("Server=.\\SQLEXPRESS;Database=DemoDB;Trusted_Connection=True;");


            //ACT
            User user = new User()
            {
                Username = "******", Password = "******", Salt = "salt", Role = "role"
            };

            userDAO.CreateUser(user);
            Food item = new Food()
            {
                Calories = 1000,
                Name     = "Salami",
                Fat      = 20,
                Carbs    = 10,
                Protein  = 30,
                MealType = "Lunch",
                Servings = 3,
                Date     = DateTime.Now,
                ndbno    = 200
            };

            foodItemDAO.AddFoodItem(user.Id, item);
            int actual = this.GetRowCount("food_entries");

            //ASSERT
            Assert.AreEqual(2, actual);
        }
        // This is an integration test comparing ability of adding an associated profile to a user
        public void CreateProfile_ShouldAddNewRowItem()
        {
            //ARRANGE
            ProfileSqlDAO profileDAO = new ProfileSqlDAO("Server=.\\SQLEXPRESS;Database=DemoDB;Trusted_Connection=True;");
            UserSqlDAO    userDAO    = new UserSqlDAO("Server=.\\SQLEXPRESS;Database=DemoDB;Trusted_Connection=True;");


            //ACT
            User user = new User()
            {
                Username = "******", Password = "******", Salt = "salt", Role = "role"
            };

            user.Id = (userDAO.CreateUser(user)).Id;

            Profile profile = new Profile()
            {
                UserId = user.Id, Name = "Name", CurrentWeight = 100, GoalWeight = 200, BirthDate = DateTime.Today, Feet = 6, Inches = 9, ActivityLevel = "moderate", Gender = 'F', Timeline = "Maintain", UserImage = ""
            };

            profileDAO.CreateProfile(profile);
            int actual = this.GetRowCount("user_profiles");

            //ASSERT
            Assert.AreEqual(2, actual);
        }
Пример #3
0
        public void Test_CreateUser()
        {
            UserSqlDAO testDAO  = new UserSqlDAO(connectionString);
            User       testUser = new User();

            testUser.Password = "******";
            testUser.Username = "******";
            testUser.Role     = "role";
            testUser.Salt     = "salt";

            Assert.AreEqual(true, testDAO.CreateUser(testUser));
        }
        // This unit test is designed to verify the CreateUser method is adding a new row on the user db table
        public void CreateUser_ShouldAddNewRowItem()
        {
            //ARRANGE
            UserSqlDAO userDAO = new UserSqlDAO("Server=.\\SQLEXPRESS;Database=DemoDB;Trusted_Connection=True;");

            //ACT
            User user = new User()
            {
                Username = "******", Password = "******", Salt = "salt", Role = "role"
            };

            userDAO.CreateUser(user);
            int actual = this.GetRowCount("users");

            //ASSERT
            Assert.AreEqual(2, actual);
        }
Пример #5
0
        public IActionResult Register(RegistrationViewModel model)
        {
            /* Place to enfore the rules */
            //Check to see if model is valid
            if (ModelState.IsValid)
            {
                //Save the new user to database
                userDAO.CreateUser(model.Email, model.Password);

                //Redirects the page to method Confirmation
                //return RedirectToAction("Confirmation");
                return(RedirectToAction("Confirmation", model));
            }

            // Return to registration screen and send the data that didn't work
            // Tell the view to display again (with the existing data that was passed in)
            return(View(model)); //This time view will display all existing data with error messages
        }