示例#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)));
        }
示例#2
0
        public void ShouldIgnoreDosagesAfterEndDateWhenCalculatingRemaining()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate, TenPerDay);
            plan.RegisterDosage(new DateTime(2014, 1, 10), FivePerDay);

            var initialStock = new Stock(100, startDate);

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

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(60, new DateTime(2014, 1, 5))));
        }
示例#3
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)));
        }
示例#4
0
        public void ShouldReturnProperStockWithOneDosage()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate, FivePerDay);

            var calculateFor = new DateTime(2014, 1, 5);
            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, calculateFor);

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(80, calculateFor)));
        }
示例#5
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)));
        }