public void GivenNonEmptyValidRepository_WhenCalledWithDefaultParameters_ShouldReturnRepositorySize() { // Arange var mappingRepo = MockRepository.GenerateStub <IRepository <ProductCategory> >(); mappingRepo.Stub(x => x.TableNoTracking).Return(_repo.AsQueryable()); // Act var cut = new ProductCategoryMappingsApiService(mappingRepo); int result = cut.GetMappingsCount(); // Assert Assert.AreEqual(_repo.Count, result); }
public void GivenNonEmptyValidRepository_WhenCalledWithSomeParameters_ShouldReturnCountOfAllItemsAccordingToParameters(int categoryId, int productId) { var expectedCount = _repo.Count(x => x.CategoryId == categoryId && x.ProductId == productId); // Arange var mappingRepo = MockRepository.GenerateStub <IRepository <ProductCategory> >(); mappingRepo.Stub(x => x.TableNoTracking).Return(_repo.AsQueryable()); // Act var cut = new ProductCategoryMappingsApiService(mappingRepo); int result = cut.GetMappingsCount(productId, categoryId); // Assert Assert.AreEqual(expectedCount, result); }