public void SteakBurnedCantEat() { // arrange var steak = new Steak("ex-Cow"); // act // assert Assert.Throws <Exception>(() => steak.AddTemp(5000)); }
public Client() { //Let's cook a steak! Steak account = new Steak("T-Bone"); // Apply temperature changes account.AddTemp(120); account.AddTemp(15); account.AddTemp(15); account.RemoveTemp(10); //Yes I know cooking doesn't work this way, bear with me. account.RemoveTemp(15); account.AddTemp(20); account.AddTemp(20); account.AddTemp(20); //Console.ReadKey(); }
/// <summary> /// The State pattern encapsulates states of an object as objects themselves, and uses a Context class /// (the Steak class in this example) to store the current state of the object and the object itself. /// </summary> /// <param name="args"></param> static void Main(string[] args) { //Let's cook a steak! Steak steak = new Steak("T-Bone"); // Apply temperature changes steak.AddTemp(120); steak.AddTemp(15); steak.AddTemp(15); steak.RemoveTemp(10); //Yes I know cooking doesn't work this way, bear with me. steak.RemoveTemp(15); steak.AddTemp(20); steak.AddTemp(20); steak.AddTemp(20); Console.ReadKey(); }
public void CookSteak_With_Design() { //Let's cook a steak! Steak account = new Steak("T-Bone"); // Apply temperature changes account.AddTemp(120); account.AddTemp(15); account.AddTemp(15); account.RemoveTemp(10); //Yes I know cooking doesn't work this way account.RemoveTemp(15); account.AddTemp(20); account.AddTemp(20); account.AddTemp(20); Assert.True(account.State.CanEat); }