Beispiel #1
0
        //TEST:  USER_DELETE_FAILURETEST
        //Test the functionality of the User Delete method when using unintended test data.
        //Because the User has already been deleted by the previous method, this will result in a value of -1 (signifying a
        // failure to delete a user), rather than the value of 1 that is returned on the successful deletion of a user.
        public void Users_Delete_FAILURETest()
        {
            SqlSecurityManager manager = new SqlSecurityManager();

            //ARRANGE
            UsersController usersController = new UsersController();
            MyDataEntities  db = new MyDataEntities();
            //ACT
            int result = manager.Delete("testRegisterUser");

            //ASSERT
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(int));
            Assert.AreEqual(result, -1);
        }
Beispiel #2
0
        //TEST:  SQLSECURITYMANAGER_DELETEUSER_TEST
        //Test the functionality of the SqlSecurityManager DeleteUser method using test data.
        public void SqlSecurityManager_DeleteUser_Test()
        {
            SqlSecurityManager manager = new SqlSecurityManager();
            MyDataEntities     db      = new MyDataEntities();

            //ARRANGE
            //Grab the test user that we created in SqlSecurityManager_RegisterUser and find their UserID to be used in the Delete method
            var userArray  = db.Users.Where(x => x.UserName == "testSqlUser").ToList();
            int testUserID = 0;

            foreach (var item in userArray)
            {
                testUserID = item.UserID;
            }
            //ACT
            int result = manager.Delete("testSqlUser");

            //ASSERT
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(int));
            Assert.AreEqual(result, 1);
        }