title: How To Write CRUD Unit Tests for Moq and Linq-to-Sql
body: <p>I am just getting involved in Moq and unit testing, so forgive me if this seems obvious (a quick search through SO didn't show me anything like this).</p>
  
  <p>I have an interface with the following proposed member:</p>
  
  <pre><code>void AddFeed(Feed feed);
  </code></pre>
  
  <p>That I would like to write a unit test for this functionality. The test class has a Moq Repository declared as follows:</p>
  
  <pre><code>static IFeedRepository MockFeedsRepository(params Feed[] feeds)
      {
          var mockFeedsRepository = new Moq.Mock&lt;IFeedRepository&gt;();
          mockFeedsRepository.Expect(x =&gt; x.Feeds).Returns((feeds.AsQueryable));
  
          return mockFeedsRepository.Object;
      }
  </code></pre>
  
  <p>How should the mock repository declaration be modified to include this new desired behavior or should I create a different Moq (and just how would that be done). </p>
  
  <p>My assumption is that after creating the mock, deriving the unit test will be much easier but hints are greatly appreciated.</p>
  
  <p>Many thanks,</p>
  
  <p>KevDog</p>