public void SimpleTest() { Context context = new Context(); context.Action(); context.Action(); context.Action(); }
public static void Launch_Strategy() { // Клиентский код выбирает конкретную стратегию и передаёт её в // контекст. Клиент должен знать о различиях между стратегиями, // чтобы сделать правильный выбор. var context = new Context(); Console.WriteLine("Однозначное число"); context.SetStrategy(new SingleDigit()); context.Action(); Console.WriteLine(); Console.WriteLine("Двухзначное число"); context.SetStrategy(new DoubleDigit()); context.Action(); Console.WriteLine(); Console.WriteLine("Многозначное число"); context.SetStrategy(new ManyDigit()); context.Action(); }
public void TestState() { var expectedFinalState = "Done(已完成)"; var actualFinalState = string.Empty; var context = new Context(); while (context.CurrentState != null) { actualFinalState = context.CurrentState.ToString(); Trace.WriteLine($"需求目前狀態={actualFinalState}"); context.Action(); } Assert.Equal(expectedFinalState, actualFinalState); }
public void ProcessKey(Gdk.ModifierType modifiers, Key key, char ch) { Context.Build(modifiers, key, ch); if (Context.Error != null) { Reset(Context.Error); } else if (Context.Action != null) { Context.Action(this); Reset(""); } else { Message = Context.Message; } }