Ejemplo n.º 1
0
        public void IsValidEmptyProductIdShouldReturnFalse()
        {
            var discount = new SalesLineItemDiscount()
            {
                Discount          = "$10",
                EffectiveFrom     = DateTime.Now.AddHours(-1),
                EffectiveTo       = DateTime.Now.AddHours(1),
                ProductId         = "", // cannot have empty product ids
                ThresholdQuantity = 1
            };

            Assert.That(discount.IsValid(), Is.False, "Empty product ID should be invalid.");
        }
Ejemplo n.º 2
0
        public void IsValidNegativeThresholdQuantityShouldReturnFalse()
        {
            var discount = new SalesLineItemDiscount()
            {
                Discount          = "$10",
                EffectiveFrom     = DateTime.Now.AddHours(-1),
                EffectiveTo       = DateTime.Now.AddHours(1),
                ProductId         = "Greek Salad",
                ThresholdQuantity = -1 // cannot have non-positive thresholds
            };

            Assert.That(discount.IsValid(), Is.False, "Non-positive threshold quantities should be invalid.");
        }
Ejemplo n.º 3
0
        public void IsValidNegativeAbsoluteDiscountShouldReturnFalse()
        {
            var discount = new SalesLineItemDiscount()
            {
                Discount          = "-10", // cannot have negative discounts
                EffectiveFrom     = DateTime.Now.AddHours(-1),
                EffectiveTo       = DateTime.Now.AddHours(1),
                ProductId         = "Granola",
                ThresholdQuantity = 3
            };

            Assert.That(discount.IsValid(), Is.False, "Negative discounts should be invalid.");
        }
Ejemplo n.º 4
0
        public void IsValidEffectiveToLessThanEffectiveFromShouldReturnFalse()
        {
            var discount = new SalesLineItemDiscount()
            {
                Discount          = "$10",
                EffectiveFrom     = DateTime.Now.AddHours(5),
                EffectiveTo       = DateTime.Now.AddHours(-5), // Cannot have To < From
                ProductId         = "Tuna Salad",
                ThresholdQuantity = 1
            };

            Assert.That(discount.IsValid(), Is.False,
                        "'Effective' time period should start at 'From' and end at to 'To'.");
        }