public void test_stock_repository_usage() { StockRepositoryTestClass repositoryTest = new StockRepositoryTestClass(); IEnumerable<Stock> stockItems = repositoryTest.GetAllStock(); Assert.IsNotNull(stockItems); }
public void test_stock_repository_usage() { StockRepositoryTestClass repositoryTest = new StockRepositoryTestClass(); IEnumerable <Stock> stockItems = repositoryTest.GetAllStock(); Assert.IsNotNull(stockItems); }
public void test_stock_repository_mocking() { List<Stock> stocks = new List<Stock>() { new Stock() { Id = 1, Notes = "Stock One" }, new Stock() { Id = 2, Notes = "Stock Two" } }; Mock<IStockRepository> mockStockRepository = new Mock<IStockRepository>(); mockStockRepository.Setup(obj => obj.Get()).Returns(stocks); StockRepositoryTestClass repositoryTest = new StockRepositoryTestClass(mockStockRepository.Object); IEnumerable<Stock> ret = repositoryTest.GetAllStock(); Assert.AreEqual(ret, stocks); }
public void test_stock_repository_mocking() { List <Stock> stocks = new List <Stock>() { new Stock() { Id = 1, Notes = "Stock One" }, new Stock() { Id = 2, Notes = "Stock Two" } }; Mock <IStockRepository> mockStockRepository = new Mock <IStockRepository>(); mockStockRepository.Setup(obj => obj.Get()).Returns(stocks); StockRepositoryTestClass repositoryTest = new StockRepositoryTestClass(mockStockRepository.Object); IEnumerable <Stock> ret = repositoryTest.GetAllStock(); Assert.AreEqual(ret, stocks); }