title: Nunit DynamicMock C# Presenter class
body: <p>im new to Nunit testing and I was hoping someone could please provide me with a brief explaination or even a link to a site where I can get a nice explaination and example code for using DynamicMock.ExpectAndReturn.</p>
  
  <p>Im trying out the MVP pattern, and my presenter class I have setup unit test as follows</p>
  
  <pre><code>mock = new DynamicMock(typeof(I_MyInterface));
  View = new MyPresenterClass((I_MyInterface)mock.MockInstance);
  view.Initialise();
  </code></pre>
  
  <p>I have a string property "Name", I wanted to make sure that the code below is a valid presenter test? I tried the following code</p>
  
  <pre><code>mock.ExpectAndReturn("get_Name", "Yoda");
  Assert.AreEqual("Yoda", ((I_MyInterface)mock.MockInstance).Name);
  </code></pre>
  
  <p>My last question is, how can I test a method form my presenter correctly returned a value and set a property correctly. For example a method</p>
  
  <pre><code>public bool NameIt(int i)
  {
       if(i&lt;20)
       {
            view.Name="Yoda";
            return true;
       }
       return false;
   }
  </code></pre>
  
  <p>Could someone please show me how I could test this via the dynamic mocking? </p>
  
  <p>Thank you in advance!</p>