예제 #1
0
        public void ImportProducts_SavingProductPrices(bool samePriceExists, int recievedAddCalls)
        {
            //arrange
            _productRepository.ClearReceivedCalls();
            _priceRepository.ClearReceivedCalls();
            _priceRepository.ClearSubstitute();
            var productPrice = 5999.0m;

            _dataReader.GetJsonFromUrl(Arg.Any <string>()).Returns(_jsonExample);
            if (samePriceExists)
            {
                _priceRepository.FindSet(x => true).ReturnsForAnyArgs(new List <Price> {
                    new Price {
                        ProductPrice = productPrice
                    }
                });
            }

            //act
            _informationImportService.ImportProducts();

            //assert
            _priceRepository.Received(recievedAddCalls).Add(Arg.Is <Price>(x => x.ProductPrice == productPrice));
        }