-1

I have a unit test which logs onto a database and checks the username and password, but I need to recreate these test now using mocks.

I have been searching online but cannot find anything like what I am trying to achieve. Below is the original test

[TestMethod()]
public void LoginTest()
{
    this.errorText = string.Empty;
    this.user = MasterDataManager.GetInstance().Login("JohnSmith", "123", out errorText);
    Assert.AreEqual(string.Empty, errorText);
}

I have written a test from what I have found online, it passes but I don't really know why to be honest. I have used Rhino Mocks here but am open to any help or solutions to get me going

[TestMethod()]
public void LoginTestMock()
{
    var repo = MockRepository.GenerateMock<IAbstractConnector>();
    repo.Login("JohnSmith", "123", out errorText);
    repo.VerifyAllExpectations();
}
gabsferreira
  • 3,089
  • 7
  • 37
  • 61
Alan Mulligan
  • 1,107
  • 2
  • 16
  • 35

1 Answers1

0

Answering your "...it passes but I don't really know why to be honest.": It passes, because you have not set any expectations, hence nothing to verify. Check,e.g.

http://en.wikibooks.org/wiki/How_to_Use_Rhino_Mocks/Introduction

rbm
  • 3,243
  • 2
  • 17
  • 28