public async Task ShouldReturnExpectedResultCodeAsync(DiscountResultCode expectedResultCode, bool isProductAvailable) { if (!isProductAvailable) { _availableProducts.Clear(); } _productRepositoryMock.Setup(x => x.GetById(_request.ProductIds)) .ReturnsAsync(_availableProducts.Where(x => x.SKU == _request.ProductIds).FirstOrDefault()); var result = await _discount.CreateDiscountAsync(_request); Assert.Equal(expectedResultCode, result.Code); }
public async Task ShouldReturnExpectedResultoCodeAsync(DiscountResultCode expectedResultCode, bool isProductAvailable) { //Arrange if (!isProductAvailable) { _availableproduct.Clear(); } _productRepositoryMock.Setup(x => x.GetById(discountRequest.ProductDescription)).ReturnsAsync(_availableproduct.FirstOrDefault()); //Act DiscountResult result = await discount.CreateDiscountAsync(discountRequest); //Assert Assert.Equal(expectedResultCode, result.Code); }