Beispiel #1
0
        public void Calculate_AboveMinimum_ShouldNotRemoveCharge()
        {
            // Arrange
            var chargeName = "VAT";
            var orderItem  = _orderItemBuilder.Build();
            var order      = _orderBuilder.WithOrderItems(new List <OrderItem> {
                orderItem
            }).Build();
            var calculator = Mock.Of <IChargeCalculator>();

            orderItem.AddCharge(new OrderCharge(chargeName, "EUR10", ChargeNames.Item));

            var sut = new MinimumCollectibleConstraint(calculator, chargeName, "EUR10");

            // Act
            sut.Calculate(order);

            // Assert
            order.GetChargeAmount(chargeName, order.Currency).Value.Should().Be(10);
        }
Beispiel #2
0
        public void Calculate_UnderMinimumMultipleItems_ShouldRemoveCharge()
        {
            // Arrange
            var chargeName = "VAT";
            var orderItem1 = _orderItemBuilder.Build();
            var orderItem2 = _orderItemBuilder.Build();
            var order      = _orderBuilder.WithOrderItems(new List <OrderItem> {
                orderItem1, orderItem2
            }).Build();
            var calculator = Mock.Of <IChargeCalculator>();

            orderItem1.AddCharge(new OrderCharge(chargeName, "EUR5", ChargeNames.Item));
            orderItem2.AddCharge(new OrderCharge(chargeName, "EUR4.99", ChargeNames.Item));

            var sut = new MinimumCollectibleConstraint(calculator, chargeName, "EUR10");

            // Act
            sut.Calculate(order);

            // Assert
            order.GetChargeAmount(chargeName, order.Currency).Value.Should().Be(0);
        }