public void ExampleShouldWork() { using (StringWriter sw = new StringWriter()) { TextWriter stdout = Console.Out; Console.SetOut(sw); TripleTacoBox trip = new TripleTacoBox(); Console.WriteLine(trip.TacosRemaining()); trip.Eat(); Console.WriteLine(trip.TacosRemaining()); trip.Eat(); Console.WriteLine(trip.TacosRemaining()); trip.Eat(); Console.WriteLine(trip.TacosRemaining()); // Try to eat one too much trip.Eat(); Console.WriteLine(trip.TacosRemaining()); Console.WriteLine(); CustomTacoBox custom = new CustomTacoBox(2); Console.WriteLine(custom.TacosRemaining()); custom.Eat(); Console.WriteLine(custom.TacosRemaining()); custom.Eat(); Console.WriteLine(custom.TacosRemaining()); // Try to eat one too much custom.Eat(); Console.WriteLine(custom.TacosRemaining()); Console.SetOut(stdout); string example = "3\n2\n1\n0\n0\n\n2\n1\n0\n0\n"; Assert.AreEqual(example, sw.ToString().Replace("\r\n", "\n"), "The example should work as such!"); } }
public void TripleTacoEatWorks() { using (StringWriter sw = new StringWriter()) { TripleTacoBox trip = new TripleTacoBox(); trip.Eat(); Assert.AreEqual(2, trip.TacosRemaining(), "Eating a taco from Triple should reduce the amount by 1!"); } }