title: Unit testing .NET Core
body: <p>im trying to write a unit test where i want to use my MockRepository for my products and filter the products by Category Id. However i am fairly new to all of this and dont really know how i can do this.</p>
  <p>This is my MockRepo for the producuts:</p>
  <pre><code>public class MockProductRepository : IProductsRepository
      {
          private readonly ICategoryRepository _categoryRepository = new MockCategoryRepository();
  
  
  
          public IEnumerable&lt;Products&gt; AllProducts =&gt;
              new List&lt;Products&gt;
              {
                  new Products {ProductId = 1, ProductName=&quot;Ek Stol&quot;, ProductPrice=150, ProductDescription=&quot;En fin stol&quot;, Category = _categoryRepository.AllCategories.ToList()[0],ImageUrl=&quot;https://cdn.pixabay.com/photo/2017/02/19/14/39/antique-2079936_960_720.jpg&quot;, ImageThumbnailUrl=&quot;https://gillcleerenpluralsight.blob.core.windows.net/files/strawberrypiesmall.jpg&quot;},
                  new Products {ProductId = 2, ProductName=&quot;Bord!&quot;, ProductPrice=250, ProductDescription=&quot;Ett fint vardagsbrod.&quot;, Category = _categoryRepository.AllCategories.ToList()[1],ImageUrl=&quot;https://cdn.pixabay.com/photo/2015/03/07/20/11/dinner-table-663435_960_720.jpg&quot;, ImageThumbnailUrl=&quot;https://gillcleerenpluralsight.blob.core.windows.net/files/cheesecakesmall.jpg&quot;},
                  new Products {ProductId = 3, ProductName=&quot;skål&quot;, ProductPrice=350, ProductDescription=&quot;Grym frukost skål!&quot;, Category = _categoryRepository.AllCategories.ToList()[0],ImageUrl=&quot;https://cdn.pixabay.com/photo/2016/03/22/12/06/sunflower-seeds-1272736_960_720.jpg&quot;, ImageThumbnailUrl=&quot;https://gillcleerenpluralsight.blob.core.windows.net/files/rhubarbpiesmall.jpg&quot;},
                  new Products {ProductId = 4, ProductName=&quot;Lådbil&quot;, ProductPrice=450,  ProductDescription=&quot;Snabbaste kärran i stan!&quot;, Category = _categoryRepository.AllCategories.ToList()[2],ImageUrl=&quot;https://cdn.pixabay.com/photo/2018/06/23/08/04/soapbox-3492256_960_720.jpg&quot;, ImageThumbnailUrl=&quot;https://gillcleerenpluralsight.blob.core.windows.net/files/pumpkinpiesmall.jpg&quot;}
              };
  
  
  
          public Products GetProductById(int ProductId)
          {
              return AllProducts.FirstOrDefault(p =&gt; p.ProductId == ProductId);
          }
      }
  }
  </code></pre>
  <p>This is my MockCategory repo:</p>
  <pre><code>namespace uppfinnaren_MarcusR91.Models
  {
      public class MockCategoryRepository : ICategoryRepository
      {
          public IEnumerable&lt;Category&gt; AllCategories =&gt;
              new List&lt;Category&gt;
          {
              new Category { CategoryId = 1, CategoryName = &quot;Stolar&quot;, Description = &quot;Alla stolar!&quot;},
              new Category { CategoryId = 2, CategoryName = &quot;Bord&quot;, Description = &quot;Alla bord!&quot;},
              new Category { CategoryId = 3, CategoryName = &quot;Lådbilar&quot;, Description = &quot;Snabbaste lådbilarna i stan!&quot;} 
          };
      }
  }
  
  </code></pre>
  <p>And what i want to do is write a unit test where i check if i can filter the products by categoryId.
  This is what i have written so far in my unit tets:</p>
  <pre><code>namespace TestProjectUppfinnaren
  {
      public class UnitTest1
      {
          [Fact]
          public void TestFilteringProductsByCategory()
          {
              var mockData = new MockProductRepository();
              
              var products =  mockData.AllProducts.Where(x =&gt; x.CategoryId == 2);
   
          } 
      }
  }
  </code></pre>
  <p>I need some sort of assert i believe that will make sure that the products and the categoryId im trying to filter should be the same. Anyone have any ideas?</p>