Beispiel #1
0
        public void UserForm_AddUserDuplicateEmailTest()
        {
            IUserViewModel  viewModel = new myUserViewModel();
            UsersController target    = new UsersController(viewModel);
            SysUser         sysUser   = new MockUserAdmin.Models.SysUser
            {
                EmailAddress = "*****@*****.**",
                Password     = "******",
                FirstName    = "User1",
                LastName     = "Test"
            };

            int UserCountBefore = viewModel.sysUsers.Count;

            ViewResult     actual = target.UserForm(sysUser);
            IUserViewModel result = (IUserViewModel)actual.Model;

            int UserCountAfter = result.sysUsers.Count;

            Assert.AreEqual(UserCountAfter, UserCountBefore);
        }
Beispiel #2
0
        public void UserForm_AddUserTest()
        {
            IUserViewModel  viewModel = new myUserViewModel();
            UsersController target    = new UsersController(viewModel);
            SysUser         sysUser   = new MockUserAdmin.Models.SysUser
            {
                EmailAddress = "*****@*****.**",
                Password     = "******",
                FirstName    = "Unique",
                LastName     = "User"
            };

            int UserCountBefore = viewModel.sysUsers.Count;

            ViewResult     actual = target.UserForm(sysUser);
            IUserViewModel result = (IUserViewModel)actual.Model;

            int UserCountAfter = result.sysUsers.Count;

            //confirm a user was added...
            Assert.AreEqual(UserCountAfter, UserCountBefore + 1);
        }
Beispiel #3
0
        public void UserForm_AddUserBadEmailTest()
        {
            IUserViewModel  viewModel = new myUserViewModel();
            UsersController target    = new UsersController(viewModel);
            SysUser         sysUser   = new MockUserAdmin.Models.SysUser
            {
                EmailAddress = "unique.123.com",
                Password     = "******",
                FirstName    = "Unique",
                LastName     = "User"
            };

            target.ModelState.AddModelError("EmailAddress", "Please enter valid Email Address");
            int UserCountBefore = viewModel.sysUsers.Count;

            ViewResult             actual = target.UserForm(sysUser);
            IList <Models.SysUser> result = (IList <Models.SysUser>)actual.Model;

            int UserCountAfter = result.Count;

            Assert.AreEqual(UserCountAfter, UserCountBefore);
        }
        public void UserForm_AddUserTest()
        {
            IUserViewModel viewModel = new myUserViewModel();
            UsersController target = new UsersController(viewModel);
            SysUser sysUser = new MockUserAdmin.Models.SysUser
            {
                EmailAddress = "*****@*****.**",
                Password = "******",
                FirstName = "Unique",
                LastName = "User"
            };

            int UserCountBefore = viewModel.sysUsers.Count;

            ViewResult actual = target.UserForm(sysUser);
            IUserViewModel result = (IUserViewModel)actual.Model;

            int UserCountAfter = result.sysUsers.Count;
            //confirm a user was added...
            Assert.AreEqual(UserCountAfter, UserCountBefore + 1);
        }
        public void UserForm_AddUserMissingFieldTest()
        {
            IUserViewModel viewModel = new myUserViewModel();
            UsersController target = new UsersController(viewModel);
            SysUser sysUser = new MockUserAdmin.Models.SysUser
            {
                EmailAddress = "*****@*****.**",
                Password = "******",
                FirstName = "Unique",
                //LastName = "User"
            };
            target.ModelState.AddModelError("LastName", "Please enter Last Name");
            int UserCountBefore = viewModel.sysUsers.Count;

            ViewResult actual = target.UserForm(sysUser);
            IList<Models.SysUser> result = (IList<Models.SysUser>)actual.Model;

            int UserCountAfter = result.Count;
            Assert.AreEqual(UserCountAfter, UserCountBefore );
        }
        public void UserForm_AddUserDuplicateEmailTest()
        {
            IUserViewModel viewModel = new myUserViewModel();
            UsersController target = new UsersController(viewModel);
            SysUser sysUser = new MockUserAdmin.Models.SysUser
            {
                EmailAddress = "*****@*****.**",
                Password = "******",
                FirstName = "User1",
                LastName = "Test"
            };

            int UserCountBefore = viewModel.sysUsers.Count;

            ViewResult actual = target.UserForm(sysUser);
            IUserViewModel result = (IUserViewModel)actual.Model;

            int UserCountAfter = result.sysUsers.Count;
            Assert.AreEqual(UserCountAfter, UserCountBefore );
        }