title: Retrieve data from MockRepository?
body: <p>I'm new to Unit Testing and I'm using Rhino Mock in ASP.NET MVC</p>
  
  <p>I have created a main test class with this code :</p>
  
  <pre><code>    [TestFixture]
      public class PersistenceTest
      {
          [Test]
          protected T SaveAndLoadEntity&lt;T&gt;(T entity) where T : BaseEntity
          {
              var mockDataSource = MockRepository.GenerateMock&lt;IRepository&lt;T&gt;&gt;();
  
              mockDataSource.Add(entity);
  
              var fromDb = mockDataSource.FindBy(entity.Id);
  
              return fromDb;
          }
      }
  </code></pre>
  
  <p>and create a customer test class like this :</p>
  
  <pre><code>    [TestFixture]
      public class CustomerTests : PersistenceTest
      {
          [Test]
          public void Can_Save_And_Load_Customer()
          {
              var customer = new Customer()
              {
                  Id = 12,
                  Name = "Reza",
                  Family = "Pazooki",
                  Company = "Rozaneh",
                  Email = "ipazooki@gmail.com",
                  Mobile = "09352463668",
                  Fax = "021-44869059",
                  Tel = "021-44869059",
                  WebSite = "www.rozanehmedia.com"
              };
  
              var fromDb = SaveAndLoadEntity(customer);
  
              fromDb.ShouldNotBeNull();
          }
      }
  </code></pre>
  
  <p>but when run the code, it says that return value from Database is NULL!!!</p>
  
  <p>I don't know what is wrong with my code but I save and retrieve data from mock repository and it seems every thing is ok.</p>
  
  <p>tnx form any help in forward :)</p>