Esempio n. 1
0
        public void ShouldReturnProperExhaustionDateWithOneDosage()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate, FivePerDay);
            var stock = new Stock(100, startDate);

            // act
            var exhaustionDate = plan.CalculateExhaustionDate(stock);

            // assert
            Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 20)));
        }
Esempio n. 2
0
        public void ShouldIgnoreDosagesPreviousToStartDate()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate.AddDays(-7), TenPerDay);
            plan.RegisterDosage(startDate, FivePerDay);

            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, new DateTime(2014, 1, 5));
            var exhaustionDate = plan.CalculateExhaustionDate(initialStock);

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(80, new DateTime(2014, 1, 5))));
            Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 20)));
        }
Esempio n. 3
0
        public void ShouldTakeIntoAccountDosagesOverlapingWithStartDate()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate.AddDays(-7), TenPerDay);
            plan.RegisterDosage(startDate.AddDays(1), FivePerDay);

            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, new DateTime(2014, 1, 5));
            var exhaustionDate = plan.CalculateExhaustionDate(initialStock);

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(75, new DateTime(2014, 1, 5))));
            Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 19)));
        }