public void CanChangeLoginName() { // Arrange (set up a scenario) User user = new User() { LoginName = "Bob" }; FakeRepository repositoryParam = new FakeRepository(); repositoryParam.Add(user); AdminController target = new AdminController(repositoryParam); string oldLoginParam = user.LoginName; string newLoginParam = "Joe"; // Act (attempt the operation) target.ChangeLoginName(oldLoginParam, newLoginParam); // Assert (verify the result) Assert.AreEqual(newLoginParam, user.LoginName); Assert.IsTrue(repositoryParam.DidSubmitChanges); }
public void CanChangeLoginName() { //Arrange (set up a scenario) User user = new User() { LoginName = "Bob" }; FakeRepository repositoryParam = new FakeRepository(); repositoryParam.Add(user); AdminController target = new AdminController(repositoryParam); string oldLoginParam = user.LoginName; string newLoginParam = "Joe"; //Act (attempt the operation) target.ChangeLoginName(oldLoginParam, newLoginParam); //Assert (verify the result) Assert.AreEqual(newLoginParam, user.LoginName); Assert.IsTrue(repositoryParam.DidSubmitChanges); }
public void CanChangeLoginName() { // Arrange User user = new User() { LoginName = "Bob" }; FakeRepository repository = new FakeRepository(); repository.Add(user); AdminController target = new AdminController(repository); string oldLogin = user.LoginName; string newLogin = "******"; // Action target.ChangeLoginName(oldLogin, newLogin); // Assert Assert.AreEqual(newLogin, user.LoginName); Assert.IsTrue(repository.DidSubmitChanges); }
public void CanChangeLoginName() { // 准备--建立场景 User user = new User() { LoginName = "Bob" }; FakeRepository repositioryParam = new FakeRepository(); repositioryParam.Add(user); AdminController target = new AdminController(repositioryParam); string oldLoginName = user.LoginName; string newLoginName = "Joe"; // 动作--尝试相应操作 target.ChangeLoginName(oldLoginName, newLoginName); // 断言--验证结果 Assert.AreEqual(newLoginName, user.LoginName); Assert.IsTrue(repositioryParam.DidSubmitChanges); }