示例#1
0
        public void CheesePriceForDay_ShouldReturnNull_GivenNoDateRecieved()
        {
            Cheese cheese = new Cheese {
                Name = "test", Price = 100M
            };

            Assert.Null(cheese.PriceForDay(DateTime.Now));
        }
示例#2
0
        public void CheesePriceForDay_ShouldReturnMax_GivenPriceOverMax()
        {
            Cheese cheese = new Cheese {
                Name = "test", Price = 100M, DateRecieved = DateTime.Now
            };

            Assert.Equal(CheeseConstants.MAX_PRICE, cheese.PriceForDay(DateTime.Now));
        }
示例#3
0
        public void CheesePriceForDay_ShouldReturnNull_GivenNullPrice()
        {
            Cheese cheese = new Cheese {
                Name = "test"
            };

            Assert.Null(cheese.PriceForDay(DateTime.Now));
        }
示例#4
0
        public void StandardCheesePriceForDay_ShouldLooseTwicePercent_GivenTwoDayOld()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese {
                Name = "test", Price = price, Type = CheeseType.Standard, DateRecieved = dateRecieved
            };
            var expectedPrice = price + price * CheeseConstants.STANARD_PRICE_DECREASE_RATE * 2;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(2)));
        }
示例#5
0
        public void StandardCheesePriceForDay_ShouldLoosePercent_GivenOneDayOldAndPriceOriginallyOverMax()
        {
            var dateRecieved = DateTime.Now;
            var price        = CheeseConstants.MAX_PRICE + 1M;

            Cheese cheese = new Cheese {
                Name = "test", Price = price, Type = CheeseType.Standard, DateRecieved = dateRecieved
            };
            var expectedPrice = price + price * CheeseConstants.STANARD_PRICE_DECREASE_RATE;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(1)));
        }
示例#6
0
        public void UniqueCheesePriceForDay_ShouldNotChange_GivenOneDayOld()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese {
                Name = "test", Price = price, Type = CheeseType.Unique, DateRecieved = dateRecieved
            };
            var expectedPrice = price;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(1)));
        }
示例#7
0
        public void FreshCheesePriceForDay_ShouldDecreasePercent_GivenOneDayOld()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese {
                Name = "test", Price = price, Type = CheeseType.Fresh, DateRecieved = dateRecieved
            };
            var expectedPrice = price + price * CheeseConstants.FRESH_PRICE_DECREASE_RATE;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(1)));
        }
示例#8
0
        public void StandardCheesePriceForDay_ShouldBeZero_GivenNegativePrice()
        {
            var dateRecieved = DateTime.Now;
            var price        = -10M;

            Cheese cheese = new Cheese {
                Name = "test", Price = price, Type = CheeseType.Standard, DateRecieved = dateRecieved
            };
            var expectedPrice = 0M;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(2)));
        }
示例#9
0
        public void SpecialCheesePriceForDay_ShouldIncreasePercent_GivenSixDaysToSell()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese {
                Name         = "test",
                Price        = price,
                Type         = CheeseType.Special,
                DateRecieved = dateRecieved,
                DaysToSell   = 7
            };
            var expectedPrice = price + price * CheeseConstants.SPECIAL_PRICE_INCREASE_RATE;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(1)));
        }
示例#10
0
        public void AgedCheesePriceForDay_ShouldIncreasePercent_GivenPassedBestBeforeDate()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese
            {
                Name           = "test",
                Price          = price,
                Type           = CheeseType.Aged,
                DateRecieved   = dateRecieved,
                BestBeforeDate = dateRecieved
            };
            var expectedPrice = price + price * CheeseConstants.AGED_PRICE_INCREASE_RATE;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(1)));
        }
示例#11
0
        public void StandardCheesePriceForDay_ShouldLoosePercent_GivenOneDayOldAndBeforeBestBeforeDateAndBeforeDaysToSell()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese
            {
                Name           = "test",
                Price          = price,
                Type           = CheeseType.Standard,
                DateRecieved   = dateRecieved,
                BestBeforeDate = dateRecieved.AddDays(2),
                DaysToSell     = 5
            };
            var expectedPrice = price + price * CheeseConstants.STANARD_PRICE_DECREASE_RATE;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(1)));
        }
示例#12
0
        public void UniqueCheesePriceForDay_ShouldNotChange_GivenPassedDaysToSell()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;

            Cheese cheese = new Cheese
            {
                Name           = "test",
                Price          = price,
                Type           = CheeseType.Unique,
                DateRecieved   = dateRecieved,
                BestBeforeDate = dateRecieved,
                DaysToSell     = 1
            };
            var expectedPrice = price;

            Assert.Equal(expectedPrice, cheese.PriceForDay(dateRecieved.AddDays(10)));
        }
示例#13
0
        public void StandardCheesePriceForDay_ShouldBeNull_GivenPassedDaysToSell()
        {
            var dateRecieved = DateTime.Now;
            var price        = 10M;
            var daysToSell   = 2;

            Cheese cheese = new Cheese
            {
                Name           = "test",
                Price          = price,
                Type           = CheeseType.Standard,
                DaysToSell     = daysToSell,
                DateRecieved   = dateRecieved,
                BestBeforeDate = dateRecieved
            };

            Assert.Null(cheese.PriceForDay(dateRecieved.AddDays(daysToSell + 1)));
        }