public void SaveTest() { // arrange var supplies = new Supplies(); supplies.AddDosage(new Medicine("VitaminumC"), DateTime.Today.AddDays(-7), new CountPerDayDosage(5)); supplies.Refill(new Medicine("VitaminumC"), new Stock(100, DateTime.Today.AddDays(-7))); supplies.AddDosage(new Medicine("VitaminumD"), DateTime.Today.AddDays(-7), new CountPerDayDosage(5)); supplies.Refill(new Medicine("VitaminumD"), new Stock(100, DateTime.Today.AddDays(-7))); supplies.AddDosage(new Medicine("VitaminumE"), DateTime.Today.AddDays(-7), new CountPerDayDosage(5)); supplies.Refill(new Medicine("VitaminumE"), new Stock(100, DateTime.Today.AddDays(-7))); var repo = new Repository(); // act var json = repo.DumpJson(supplies); var readed = repo.ReadJson(json); var jsonForRestored = repo.DumpJson(readed); // assert Console.WriteLine(jsonForRestored); Assert.That(json, Is.EqualTo(jsonForRestored)); }
public void Bug_MixedValuesInJson() { // arrange var dx = new Medicine("DX"); var p = new Medicine("P"); var d5 = new Medicine("D5"); var d3 = new Medicine("D3"); var original = new Supplies(); original.AddDosage(dx, new DateTime(2013, 12, 21), new CountPerDayDosage(3)); original.AddDosage(p, new DateTime(2013, 12, 21), new CountPerDayDosage(1)); original.AddDosage(d5, new DateTime(2013, 12, 21), new CountPerDayDosage(2)); original.AddDosage(d3, new DateTime(2013, 11, 27), new CountPerDayDosage(1)); original.Refill(new Dictionary<Medicine, Stock> { {dx, new Stock(205, new DateTime(2013, 12, 21))}, {p, new Stock(60, new DateTime(2013, 12, 21))}, {d5, new Stock(181, new DateTime(2013, 12, 21))}, {d3, new Stock(100, new DateTime(2013, 11, 27))}, }); var repo = new Repository(); // act var json = repo.DumpJson(original); var restored = repo.ReadJson(json); // assert Console.WriteLine(json); foreach (var medicine in original.GetMedicines()) { Assert.That(restored.CurrentStock(medicine), Is.EqualTo(original.CurrentStock(medicine)), "CurrentStock: " + medicine.Name); Assert.That(restored.ExhaustionOf(medicine), Is.EqualTo(original.ExhaustionOf(medicine)), "ExhaustionDate: " + medicine.Name); Assert.That(restored.RemainingStock(medicine, DateTime.Today), Is.EqualTo(original.RemainingStock(medicine, DateTime.Today)), "RemainingStock: " + medicine.Name); } }
public void RemainingStockShouldBeBasedOnDosageAndRefill() { // arrange var supplies = new Supplies(); supplies.AddDosage(VitaminumC, new DateTime(2014, 1, 1), FivePerDay); supplies.Refill(VitaminumC, new Stock(100, new DateTime(2014, 1, 1))); // act var remaining = supplies.RemainingStock(VitaminumC, new DateTime(2014, 1, 5)); // assert Assert.That(remaining, Is.EqualTo(new Stock(80, new DateTime(2014, 1, 5)))); }
public void ExhaustionDateShouldBeBasedOnDosageAndRefill() { // arrange var supplies = new Supplies(); supplies.AddDosage(VitaminumC, new DateTime(2014, 1, 1), FivePerDay); supplies.Refill(VitaminumC, new Stock(100, new DateTime(2014, 1, 1))); // act var exhaustionDate = supplies.ExhaustionOf(VitaminumC); // assert Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 20))); }
public void MultipleRefillShouldUpdateStockInProperWay() { // arrange var supplies = new Supplies(); supplies.AddDosage(VitaminumC, new DateTime(2014, 1, 1), FivePerDay); supplies.Refill(VitaminumC, new Stock(100, new DateTime(2014, 1, 1))); supplies.Refill(VitaminumC, new Stock(50, new DateTime(2014, 1, 5))); // act var stock = supplies.CurrentStock(VitaminumC); // assert Assert.That(stock, Is.EqualTo(new Stock(130, new DateTime(2014, 1, 5)))); }