예제 #1
0
            public void ItemId_and_Discount_properties_should_comply_with_construction_parameters()
            {
                var subject = new FlatXPercentOff("item-1", 0.30m);

                Assert.That(subject.ItemId, Is.EqualTo("item-1"));
                Assert.That(subject.Discount, Is.EqualTo(0.3m));
            }
예제 #2
0
            public void Should_return_discounted_price_for_matching_orderitem()
            {
                var subject   = new FlatXPercentOff("item-1", 0.10m);
                var orderItem = new OrderItem {
                    Identifier = "item-1", ItemCost = 50m, Quantity = 10
                };

                Assert.That(subject.CalculateItemPrice(orderItem), Is.EqualTo(500m * 0.9m));
            }
예제 #3
0
            public void Should_throw_ArgumentException_for_non_matching_orderitem()
            {
                var subject   = new FlatXPercentOff("item-1", 0.15m);
                var orderItem = new OrderItem {
                    Identifier = "item-2", ItemCost = 50m, Quantity = 10
                };

                Assert.Throws <ArgumentException>(() => subject.CalculateItemPrice(orderItem));
            }
예제 #4
0
            public void Should_return_true_for_matching_item()
            {
                var subject   = new FlatXPercentOff("item-1", 0.15m);
                var orderItem = new OrderItem {
                    Identifier = "item-1", ItemCost = 50m, Quantity = 10
                };

                Assert.IsTrue(subject.MatchesItem(orderItem));
            }
예제 #5
0
            public void Should_not_match_when_order_is_null()
            {
                var subject = new FlatXPercentOff("item-1", 0.3m);

                Assert.IsFalse(subject.MatchesItem(null));
            }
예제 #6
0
            public void Name_should_contain_the_discount_percentage_and_off()
            {
                var subject = new FlatXPercentOff("item-1", 0.30m);

                Assert.IsTrue(subject.Name.Contains(string.Format("{0:p2} off", 0.3m)));
            }