public static void Run() { Console.WriteLine($"{Environment.NewLine}*** STATE PATTERN ***{Environment.NewLine}"); Bike bike = new Bike("Rob"); // Road Bike bike.Display(); // Hybrid Bike bike.Add(ComponentType.Shocks); bike.Display(); // Mountain Bike bike.Add(ComponentType.DiscBrakes); bike.Display(); // Road Bike bike.Remove(ComponentType.DiscBrakes); bike.Remove(ComponentType.Shocks); bike.Display(); }
public void Bike_AddComponent_ChangesState() { // Arrange Bike bike = new Bike("Rob"); System.Type firstType = bike.State.GetType(); // Act bike.Add(ComponentType.Shocks); System.Type secondType = bike.State.GetType(); // Assert Assert.IsFalse(firstType == secondType); }