Reputation: 1837
I am trying to write a test method to check if the List is being obtained properly.I am very new to MSTest and Rhino Mocks.Till now I have written the below code.
var mockRepository = new MockRepository();
var menuRepository = mockRepository.DynamicMock<IMenuManager>();
var expected = new List<Menu>();
//Need to set expected value
var actual = menuRepository.GetMenus();
Assert.AreEqual(expected, actual);
IMenuManager is as below
public interface IMenuManager
{
List<Menu> GetMenus();
}
Test method itself:
var myMenuList = new List<Menu>(); var menuManagerMock = MockRepository.GenerateMock<IMenuManager>();
menuManagerMock.Stub(c => c.GetMenus()).Return(myMenuList);
actual = menuManagerMock.GetMenus();
How can I set the expected value in this scenario. Please suggest.GetMenus() reads an XML file and builds a collection.
Thanks
Upvotes: 0
Views: 180
Reputation: 4489
var myMenuList = new List<Menu>();
// setup the list from XML
var menuManagerMock = MockRepository.GenerateMock<IMenuManager>();
menuManagerMock.Stub(c => c.GetMenus()).Return(myMenuList);
Upvotes: 2