예제 #1
0
        public void Return_True()
        {
            //Arrange
            IDictionary <string, PriceModel> books = new Dictionary <string, PriceModel>();

            books.Add("Test", new PriceModel()
            {
                AvailableQuantity = 2,
                CategoryName      = "Test",
                HaveDiscount      = false,
                Price             = 4,
                Quantity          = 2
            });

            books.Add("Test2", new PriceModel()
            {
                AvailableQuantity = 2,
                CategoryName      = "Test",
                HaveDiscount      = false,
                Price             = 4,
                Quantity          = 2
            });

            var rule = new SeveralBooksRule();

            //Act
            var result = rule.MatchCondition(books);

            //Assert
            Assert.AreEqual(true, result);
        }
예제 #2
0
        public void Not_Make_Discount_When_Dont_Have_2_Catalogs_With_Same_Category()
        {
            //Arrange
            IDictionary <string, PriceModel> books = new Dictionary <string, PriceModel>();

            books.Add("Test", new PriceModel()
            {
                AvailableQuantity = 2,
                CategoryName      = "Test1",
                HaveDiscount      = false,
                Price             = 4,
                Quantity          = 2
            });

            books.Add("Test2", new PriceModel()
            {
                AvailableQuantity = 2,
                CategoryName      = "Test2",
                HaveDiscount      = false,
                Price             = 4,
                Quantity          = 2
            });

            var rule = new SeveralBooksRule();

            //Act
            var result = rule.CalculateDiscount(books);

            //Assert
            Assert.AreEqual(false, result["Test"].HaveDiscount);
            Assert.AreEqual(false, result["Test2"].HaveDiscount);
        }