public void get_should_return_the_sum_total_for_the_non_promotional_only()
        {
            var productsStubData = new GetProductsStubData();

            var productsData = productsStubData.GetProductsData();

            var sku = "B";

            var quantity = 5;

            var expected = 30m;

            _mockGetProductsStubData.Setup(x => x.GetProductsData()).Returns(productsData);

            var sut = CreateSUT();

            var response = sut.Get(sku, quantity);

            Assert.AreEqual(response, expected);
        }
        public void get_should_return_the_sum_total_for_the_non_promotional_when_no_promo_present()
        {
            var productsStubData = new GetProductsStubData();

            var productsData = productsStubData.GetProductsData();

            var sku = "C";

            var quantity = 3;

            var expected = 60m;

            _mockGetProductsStubData.Setup(x => x.GetProductsData()).Returns(productsData);

            var sut = CreateSUT();

            var response = sut.Get(sku, quantity);

            Assert.AreEqual(expected, response);
        }
Exemplo n.º 3
0
        public void Get_should_add_up_the_products_cost_using_the_prices_set_in_Products_stub_data()
        {
            var getProductsStubData = new GetProductsStubData();

            var stubData = getProductsStubData.GetProductsData();

            var scanned = new Dictionary <string, int>();

            scanned.Add("A", 4); // 180m
            scanned.Add("B", 2); // 45m
            scanned.Add("D", 4); // 60m

            _mockGetTotalPricePerSku.Setup(x => x.GetPrice("A", 4)).Returns(180m);
            _mockGetTotalPricePerSku.Setup(x => x.GetPrice("B", 2)).Returns(45m);
            _mockGetTotalPricePerSku.Setup(x => x.GetPrice("D", 4)).Returns(60m);

            var expected = 285.0m;

            var sut = CreateSUT();

            var response = sut.GetGrandTotal(scanned);

            Assert.AreEqual(expected, response);
        }