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 TripleTacoEatFourWorks() { using (StringWriter sw = new StringWriter()) { TripleTacoBox trip = new TripleTacoBox(); trip.Eat(); trip.Eat(); trip.Eat(); trip.Eat(); Assert.AreEqual(0, trip.TacosRemaining(), "Eating 4 tacos from Triple should reduce the amount by only 3!"); } }