//TEST: SQLSECURITYMANAGER_LOADUSER_FAILURETEST //Test the functionality of the SqlSecurityManager LoadUser method when using unintended test data. //Loading a username that is not owned by any User will simply return a null User. public void SqlSecurityManager_LoadUser_FAILURETest() { SqlSecurityManager manager = new SqlSecurityManager(); MyDataEntities db = new MyDataEntities(); //ARRANGE User test; string username = "******"; //ACT test = manager.LoadUser(username); //ASSERT Assert.AreEqual(0, test.UserID); Assert.IsNull(test.UserName); Assert.IsNull(test.Password); }
//TEST: SQLSECURITYMANAGER_LOADUSER_TEST //Test the functionality of the SqlSecurityManager LoadUser method using test data. public void SqlSecurityManager_LoadUser_Test() { SqlSecurityManager manager = new SqlSecurityManager(); MyDataEntities db = new MyDataEntities(); //ARRANGE //Grab the test user that we created in SqlSecurityManager_RegisterUser and find their UserID var userArray = db.Users.Where(x => x.UserName == "testSqlUser").ToList(); int testUserID = 0; foreach (var item in userArray) { testUserID = item.UserID; } //These parameters refer to the test user that we created in SqlSecurityManager_RegisterUser User test; string username = "******"; //ACT test = manager.LoadUser(username); //ASSERT Assert.AreEqual(testUserID, test.UserID); }