public void CheckAuthenticationTest() { //arrange // 初始化StubAccountDao,來當作IAccountDao的執行個體 IAccountDao dao = new StubAccountDao(); //初始化StubHash,來當作IHash的執行個體 IHash hash = new StubHash(); // 將自訂的兩個stub object,注入到目標物件中,也就是Validation物件 Validation target = new Validation(dao, hash); string id = "id隨便啦"; string password = "******"; // 期望為true,因為預期hash後的結果是"91",而IAccountDao回來的結果也是"91",所以為true bool expected = true; //act bool actual; actual = target.CheckAuthentication(id, password); //assert Assert.AreEqual(expected, actual); }
public void CheckAuthenticationTest() { IAccountDao accountDao = new StubAccountDao(); IHash hash = new StubHash(); Validation target = new Validation(accountDao, hash); string id = "id"; string pwd = "pwd"; bool expected = true; bool actual; actual = target.CheckAuthenticationTest(id, pwd); Assert.AreEqual(expected, actual); }
public void CheckAuthenticationTest() { //arrange IAccountDao dao = new StubAccountDao(); IHash hash = new StubHash(); Validation target = new Validation(dao, hash); string id = string.Empty; string password = string.Empty; //action bool expected = true; bool actual; actual = target.CheckAuthentication(id, password); //assert Assert.AreEqual(expected, actual); }
public void CheckAuthenticationTest() { //Arrange IAccountDao accDao = new StubAccountDao(); IHash hash = new StubHash(); IRandomGenerator random = new RandomGenerator(); Validation target = new Validation(accDao, hash, random); string id = "admin"; //string.Empty; string password = "******" + random.RandomStr; //string.Empty; bool expected = true; bool actual; //Act actual = target.CheckAuthentication(id, password); //Assert Assert.AreEqual(expected, actual); //Assert.Inconclusive("验证这个测试方法的正确性."); }