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)))); }
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))); }
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))); }
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))); }