public void TestChangeHistory() { using (StringWriter sw = new StringWriter()) { TextWriter stdout = Console.Out; Console.SetOut(sw); ProductWarehouse juice = new ProductWarehouse("Juice", 1000); ChangeHistory cs = new ChangeHistory(); cs.Add(100); cs.Add(10); cs.Add(200); cs.Add(50); Console.WriteLine(cs); Console.SetOut(stdout); string example = "Current: 50 Min: 10 Max: 200\n"; Assert.AreEqual(example, sw.ToString().Replace("\r\n", "\n"), "Changehistory should work like in the example!"); } }
public ProductWarehouseWithHistory(string productName, int capacity, int initialBalance) : base(productName, capacity) { history = new ChangeHistory(); this.balance = initialBalance; history.Add(initialBalance); }