public void CannotBeReducedBelowZero() { // arrange var initialStock = new Stock(100, new DateTime(2014, 1, 1)); // act var reduced = initialStock.Reduce(120, new DateTime(2014, 2, 2)); // assert Assert.That(reduced, Is.EqualTo(new Stock(0, new DateTime(2014, 2, 2)))); }
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))); }
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))); }
public StockTest() { st = Enhancer.Enhancer.Build <Stock>("Apple", "Dow Jones"); }