public ProductServiceTest() { this._productListStub = StubGenerator.GetProductsListStub(); this._productRepositoryMock = new Mock <IProductRepository>(); this._productRepositoryMock .Setup(p => p.GetProducts()) .Returns(this._productListStub); foreach (Product product in this._productListStub) { this._productRepositoryMock .Setup(p => p.GetProductById(product.Id)) .Returns(product); } this._service = new ProductService(this._productRepositoryMock.Object); }
public OrderServiceTest() { this._ordersInDateRangeStub = StubGenerator.GetOrdersListStub(); this._productListStub = StubGenerator.GetProductsListStub(); this._orderRespositoryMock = new Mock <IOrderRepository>(); this._orderRespositoryMock .Setup(o => o.GetOrdersInDateRange(It.IsAny <DateRange>())) .Returns(this._ordersInDateRangeStub); this._productRepositoryMock = new Mock <IProductRepository>(); this._productRepositoryMock .Setup(p => p.GetProducts()) .Returns(this._productListStub); for (int i = 0; i < this._productListStub.Count; i++) { this._productRepositoryMock .Setup(p => p.GetProductById(this._productListStub[i].Id)) .Returns(this._productListStub[i]); } this._service = new OrderService(this._orderRespositoryMock.Object, this._productRepositoryMock.Object); }