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