vendredi 18 décembre 2015

Mock object framework

I need to implement configurable mock object following test cases (the expected outputs can be set at runtime and the verification can be done by the mock object itself) without using a mock object framework and a test method using this configurable mock object to implement the same test case below. How can I do this? Thanks for all response.

[TestMethod]

public void SaveOrderAndVerifyExpectations(){

MockRepository mocks = new MockRepository();
IShopDataAccess dataAccess = mocks.CreateMock<IShopDataAccess>();

Order o = new Order(6, dataAccess);
o.Lines.Add(1234, 1);
o.Lines.Add(4321, 3);

// Record expectations
dataAccess.Save(6, o);

// Start replay of recorded expectations
mocks.ReplayAll();

o.Save();

mocks.VerifyAll();

}

Aucun commentaire:

Enregistrer un commentaire