mardi 28 juillet 2015

Rhino Mock expect property throws an error

Hello I am kind of a beginner level with TDD and using RhinoMocks for creating moqs in application. I am trying to implement MVP pattern

Here is my interface

public interface IView
{
   List<Bundle> DisplayList { get; set; }  
}

and my Presenter class

public class Presenter
{
    private IView View;
    public Presenter(IView view)
    {
        View = view;            
    }

    public void Bind()
    { 
        // I am creating a dummy list in MockDataLayer and SelectAll Method returns the whole list
        IDataLayer dsl=new MockDataLayer();
        View.DisplayList = dsl.SelectAll();
    } 
}

Below is my test class

public class PresenterTest 
{

    private IView _view;
    private Presenter _controller;

    [Test]
    public void View_Display_List()
    {
        //Arrange
        _view = MockRepository.GenerateMock<IView>();
        List<Bundle> objTest = new List<Bundle>();            
        _controller = new Presenter(_view);
        _view.Expect(v => v.DisplayList).Return(objTest);

        //Act
        _controller.Bind();

        //Assert
        _view.VerifyAllExpectations();
    }
}

When I execute my test, I recieve this error:

depaulOAR.PatchBundleTesting.Test.BundlePresenterTest.BundleView_Display_Bundle_List:
Rhino.Mocks.Exceptions.ExpectationViolationException : IBundleView.get_DisplayList(); Expected #1, Actual #0.

Any help will be highly appreciated.

Aucun commentaire:

Enregistrer un commentaire