public void Delete_WhenTwoExistingUsers_ExpectedResultCount1() { //Arrange var DALStub = new AdminUserDALStub(); var defaultAdminUser = new AdminUserModelDAL { Username = "******", HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("1234") }; var adminUserToDelete = new AdminUserModelDAL { Username = "******", HashedPassword = PasswordHelperTool.PasswordSHA256Hasher("torspassword") }; bool successfullCreate = DALStub.Create(adminUserToDelete); var expectedResult = new List <AdminUserModelDAL>(); expectedResult.Add(defaultAdminUser); //Act bool successfullDelete = DALStub.Delete("tor"); var result = DALStub.GetAll(); //Assert Assert.IsTrue(successfullCreate); // Here to make sure the test doesnt pass from it's target not existing Assert.IsTrue(successfullDelete); // Test to se if Delete() is executed Assert.IsTrue(result.Count == 1); // Test to se if Count is back to one for (int i = 0; i < result.Count; i++) // Test to se if correct user has been deleted by comparing to expectations { Assert.AreEqual(expectedResult[i].Username, result[i].Username); } }
public void Delete_WhenTargetNotExists_ExpectedResultFalse() { //Arrange var DALStub = new AdminUserDALStub(); //Act bool test = DALStub.Delete("tor"); //Assert Assert.IsFalse(test); }
public void GetAll_WhenNoExistingUsers_ExpectedResultNull() { //Arrange var DALStub = new AdminUserDALStub(); bool successFullDelete = DALStub.Delete("admin"); //Act var result = DALStub.GetAll(); //Assert Assert.IsNull(result); }
public void Delete_WhenOneExistingUser_ExpectedResultCount0EqualsNull() { //Arrange var DALStub = new AdminUserDALStub(); //Act bool successfullDelete = DALStub.Delete("admin"); var result = DALStub.GetAll(); //Assert Assert.IsTrue(successfullDelete); Assert.IsNull(result); }