public GameLoopDialogue(UserDialogue.WriteMethod write,long C_Id) { this.write = write; this.C_Id = C_Id; container = new DataContainer(); container.c_data = new CharacterData(ref container, C_Id); container.r_data = new Room(ref container); c_engine = new CommandEngine(write, container); writeStartMessage(); }
public async Task Test_InsertsAsync_WithImplicitTransaction() { this.helper.CreateTable(); Command command = this.helper.GetInsert(); CommandEngine engine = this.helper.GetCommandEngine(); try { await engine.ExecuteAsync(command); } catch (DbException) { } this.helper.VerifyTransaction(); }
public async Task Test_MultiInsertAsync_WithExplicitTransaction() { this.helper.CreateTable(); Command[] commands = this.GetMultiInsertCommands(); CommandEngine engine = this.helper.GetCommandEngine(new TransactionFilter()); try { await engine.ExecuteAsync(commands); } catch (DbException) { } this.helper.VerifyTransaction(); }
public void Test_Inserts_WithImplicitTransaction() { this.helper.CreateTable(); Command command = this.helper.GetInsert(); CommandEngine engine = this.helper.GetCommandEngine(); try { engine.Execute(command); } catch (DbException) { } this.helper.VerifyTransaction(); }
public void Test_MultiInsert_WithExplicitTransactionScope() { this.helper.CreateTable(); Command[] commands = this.GetMultiInsertCommands(); CommandEngine engine = this.helper.GetCommandEngine(new TransactionScopeFilter()); try { engine.Execute(commands); } catch (DbException) { } this.helper.VerifyTransaction(); }
public void Initialize() { RootCommand Root = new RootCommand(Log.Console); Root.RegisterCommand(new GoToRoomCommand(Map)); Root.RegisterCommand(new RoomInfoCommand(Map)); Root.RegisterCommand(new ListRoomsCommand(Map)); Root.RegisterCommand(new SetViewCommand(MapRenderer)); Root.RegisterCommand(new OutlineCommand(MapRenderer)); Root.RegisterCommand(new DisplayCommand(GameController)); Root.RegisterCommand(new DisableCommand(MapRenderer)); CommandEngine Engine = new CommandEngine(Root); Engine.Run(new string[0]); }
public void build() { Text = Text.Replace("\n", ""); if (Type == TypeOfCommand.Eval) { HTML = CommandEngine.getHTMLEval(Text); } else if (Type == TypeOfCommand.Plot) { HTML = CommandEngine.getHTMLPlot(Text); } else { HTML = Text; } }
public void Should_prompt_cursor() { //Arrange var consoleManager = new FakeConsoleManager(); var console = new TestConsole(consoleManager); var command = new RootCommand(console); var commandEngine = new CommandEngine(command); //Act Task.Run(() => { commandEngine.Start(new string[] { }); }).Wait(100); //Assert //TODO: Fix on build server! Assert.That(consoleManager.LineOutput[0], Is.EqualTo("> ")); //TODO: Fix on build server! Assert.That(consoleManager.CursorTop, Is.EqualTo(0)); //TODO: Fix on build server! Assert.That(consoleManager.CursorLeft, Is.EqualTo(2)); }
private static void Main(string[] args) { var console = new ClientConsole(); Effort.Provider.EffortProviderConfiguration.RegisterProvider(); var connection = DbConnectionFactory.CreateTransient(); using (var context = new SampleDb(connection, "geo")) { console.WriteLine("Welcome to EF Test Console, type help to check available commands", OutputLevel.Information, null); context.Products.AddRange(new[] { new Product { Name = "CocaCola" }, new Product { Name = "Pepsi" }, new Product { Name = "Starbucks" }, new Product { Name = "Donut" } }); context.SaveChanges(); var ct = new System.Threading.CancellationToken(); Task.Run(() => { SingletonSampleJob.Instance.RunBackgroundWork(ct); }, ct); var command = new RootCommand(console); command.RegisterCommand(new FillOrderCommand(context)); command.RegisterCommand(new EditOrder(context)); command.RegisterCommand(new QueryAuditTrail(context)); command.RegisterCommand(new QueryOrder(context)); command.RegisterCommand(new ToggleController(context)); command.RegisterCommand(new JobController(context)); var commandEngine = new CommandEngine(command); commandEngine.Run(args); } }
public static void Main(string[] args) { //LoadedAssembly(); if (args.Length == 0) { SwitchDomainForRazorEngine(); } var console = new ClientConsole(); var command = new RootCommand(console); var razorcmd = new RazorCommand(); command.RegisterCommand(razorcmd); command.RegisterCommand(new TestCaseCommand(razorcmd)); var commandEngine = new CommandEngine(command); commandEngine.Run(args); }
private static void Main(string[] args) { var config = new ConsoleConfiguration { SplashScreen = "Best Bank ever" }; using (var console = new ClientConsole(config)) { var rootCommand = new RootCommand(console); rootCommand.RegisterCommand(Container.GetInstance <Kontener.InterfejsBanku>()); var commandEngine = new CommandEngine(rootCommand); commandEngine.Start(args); } }
public void Parse_command_with_params() { var flag = false; var p = new string[2]; CommandEngine.CommandContainer.Register(new CommandRegistration("sample").AddAction((args) => { flag = true; p = args; })); CommandEngine.Initialize(); CommandEngine.ParseCommand("sample -a:5 -b:7"); flag.Should().Be(true); p.Should().Contain(new string[] { "-a:5", "-b:7" }); }
public void Execute(CommandEngine engine, ActionConfig action, Dictionary <string, string> args) { try { string repeatStr; int repeat; if (!args.TryGetValue("repeat", out repeatStr) || !int.TryParse(repeatStr, out repeat)) { repeat = 1; } repeat = Math.Max(repeat, 1); var value = action["Key"]; foreach (var kvp in args) { value = value.Replace("%" + kvp.Key + '%', kvp.Value); } for (int i = 0; i < repeat; ++i) { bool winKey = value.IndexOf("{WIN}") != -1; if (winKey) { value = value.Replace("{WIN}", ""); KeyDown(Keys.LWin); } SendKeys.SendWait(value); if (winKey) { KeyUp(Keys.LWin); } Thread.Sleep(1); } } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); } }
public void Should_work_with_commands() { //Arrange var console1 = new TestConsole(new FakeConsoleManager()); var console2 = new TestConsole(new FakeConsoleManager()); var command1 = new RootCommand(console1); var command2 = new RootCommand(console2); var commandEngine1 = new CommandEngine(command1); var commandEngine2 = new CommandEngine(command2); //Act command1.Execute("help"); //Assert Assert.That(console1.CursorLeft, Is.EqualTo(0)); Assert.That(console2.CursorLeft, Is.EqualTo(0)); Assert.That(console1.CursorTop, Is.EqualTo(26)); Assert.That(console2.CursorTop, Is.EqualTo(0)); }
public void Should_prompt_cursor_after_full_line_output() { //Arrange var consoleManager = new FakeConsoleManager(); var console = new TestConsole(consoleManager); var command = new RootCommand(console); var commandEngine = new CommandEngine(command); Task.Run(() => { commandEngine.Start(new string[] { }); }).Wait(100); //Act console.Output(new WriteEventArgs(new string('A', console.BufferWidth))); //Assert Assert.That(consoleManager.LineOutput[0], Is.EqualTo(new string('A', console.BufferWidth))); //TODO: Fix on build server! Assert.That(consoleManager.LineOutput[1], Is.EqualTo("> ")); //TODO: Fix on build server! Assert.That(consoleManager.CursorTop, Is.EqualTo(1)); //TODO: Fix on build server! Assert.That(consoleManager.CursorLeft, Is.EqualTo(2)); }
public void Initialize() { engine = new CommandEngine(AnalysisPanel); ButtonExecute.Click += new RoutedEventHandler(button_Click); TextBox.PreviewKeyUp += new KeyEventHandler(textBox_PreviewKeyUp); ToolTipService.SetShowDuration(TextBlockResult, 60000); ToolTipService.SetInitialShowDelay(TextBlockResult, 500); AnalysisPanel.Analysis.Events.PropertyChanged += new PropertyChangedEventHandler(analysisPanel_PropertyChanged); TextBox.MouseEnter += new MouseEventHandler(TextBox_MouseEnter); TextBox.MouseLeave += new MouseEventHandler(TextBox_MouseLeave); Properties.Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Default_PropertyChanged); Visibility = SetVisibility(); this.LostFocus += new RoutedEventHandler(CommandPanel_LostFocus); }
private static void Main(string[] args) { using (var console = new ClientConsole()) { var connection = new ExampleContext(console).Connection; var container = InjectionHelper.GetIocContainer(connection); var rootCommand = new RootCommand(console, new CommandResolver(type => (ICommand)container.Resolve(type))); rootCommand.RegisterCommand <ConnectionConsoleCommands>(); rootCommand.RegisterCommand <ConfigurationConsoleCommands>(); rootCommand.RegisterCommand <TimeConsoleCommands>(); rootCommand.RegisterCommand <SimulatorConsoleCommands>(); rootCommand.RegisterCommand <LightConsoleCommand>(); rootCommand.RegisterCommand <TextConsoleCommand>(); rootCommand.RegisterCommand <BeepConsoleCommand>(); rootCommand.RegisterCommand <RawDataConsoleCommands>(); var engine = new CommandEngine(rootCommand); engine.Start(args); } }
//TODO: There is an issue with this case, find a good way to set up the test for this. public void Should_output_on_new_line_when_entering_a_long_query_line_with_cursor_at_end() { //TODO: Prepare a query entry that is longer than one line //TODO: Place cursor at end of the input buffer and press enter. //Arrange var fakeKeyInput = new FakeKeyInputEngine(); var consoleManager = new FakeConsoleManager(fakeKeyInput); var console = new TestConsole(consoleManager); var command = new RootCommand(console); var commandEngine = new CommandEngine(command); console.Output(new WriteEventArgs("a")); command.Execute(new string('x', console.BufferWidth + 1)); console.Output(new WriteEventArgs("z")); //Assert.That(consoleManager.LineOutput[0], Is.EqualTo("abc")); //Assert.That(consoleManager.LineOutput[1], Is.Null); //Act //Assert }
public void Should_keep_buffer_after_line_output() { //Arrange var inputEngine = new Mock <IKeyInputEngine>(MockBehavior.Strict); inputEngine.Setup(x => x.ReadKey(It.IsAny <CancellationToken>())).Returns(new ConsoleKeyInfo('A', ConsoleKey.A, false, false, false)); var consoleManager = new FakeConsoleManager(inputEngine.Object); var console = new TestConsole(consoleManager); var command = new RootCommand(console); var commandEngine = new CommandEngine(command); Task.Run(() => { commandEngine.Start(new string[] { }); }).Wait(100); //Act console.Output(new WriteEventArgs("A")); //Assert Assert.That(consoleManager.LineOutput[0], Is.EqualTo("A")); Assert.That(consoleManager.LineOutput[1], Is.EqualTo($"{Constants.Prompt}A")); Assert.That(consoleManager.CursorTop, Is.EqualTo(1)); Assert.That(consoleManager.CursorLeft, Is.EqualTo(5)); }
static void Main(string[] args) { string a = "setup -testset testset.txt -config config.txt"; string[] bs = a.Split(' '); int i; //TODO:DFunc.Dir = System.Environment.CurrentDirectory; //load command if (!CommandReader.load(bs)) { return; } CommandEngine.run(CommandReader.Command, CommandReader.Options); String testsetPath = "Testset.txt"; Test[] tests = TestsReader.getTests(testsetPath); String testName = "DTest"; //Get class type Type testType = typeof(Test1.DTest); //Get class instance object test = Activator.CreateInstance(testType); //Get case1 and exec i = 1; runTest(testType, test, i, testName); i = 2; runTest(testType, test, i, testName); Thread.Sleep(10000); }
public void Should_a_short_string() { //Arrange var consoleManager = new FakeConsoleManager(); var console = new TestConsole(consoleManager); var command = new RootCommand(console); var commandEngine = new CommandEngine(command); Task.Run(() => { commandEngine.Start(new string[] { }); }).Wait(100); console.Output(new WriteEventArgs(new string('A', console.BufferWidth * (console.BufferHeight - 1)))); //Act console.Output(new WriteEventArgs("B")); //Assert Assert.That(consoleManager.LineOutput[0], Is.EqualTo(new string('A', consoleManager.BufferWidth))); Assert.That(consoleManager.LineOutput[consoleManager.BufferHeight - 3], Is.EqualTo(new string('A', consoleManager.BufferWidth))); Assert.That(consoleManager.LineOutput[consoleManager.BufferHeight - 2], Is.EqualTo("B")); //TODO: Fix on build server! Assert.That(consoleManager.LineOutput[consoleManager.BufferHeight - 1], Is.EqualTo("> ")); //TODO: Fix on build server! Assert.That(consoleManager.CursorTop, Is.EqualTo(consoleManager.BufferHeight - 1)); //TODO: Fix on build server! Assert.That(consoleManager.CursorLeft, Is.EqualTo(2)); }
public async Task Test_CommandEngine_Connection() { var connection1 = new SqliteConnection(DatabaseHelper.TestDbConnectionString); var connection2 = new SqliteConnection(DatabaseHelper.TestDbConnectionString); try { CommandOptions options1 = new CommandOptions() { ConnectionFactory = () => connection1, }; CommandOptions options2 = new CommandOptions() { ConnectionFactory = () => connection2, }; CommandEngine engine1 = new CommandEngine(options1); CommandEngine engine2 = new CommandEngine(options2); engine1.Execute(new Command() { CommandText = "SELECT 0;" }); await engine2.ExecuteAsync(new Command() { CommandText = "SELECT 0;" }); connection1.State.ShouldBe(ConnectionState.Closed); connection2.State.ShouldBe(ConnectionState.Closed); } finally { connection1.Dispose(); connection2.Dispose(); } }
public void Process(JObject command, Context context) { var file = JSONUtil.GetText(command, "#save-json"); if (file == null) { file = JSONUtil.GetText(command, "file"); } string set = CommandEngine.GetCommandArgument(command, "set"); string mode = JSONUtil.GetText(command, "mode"); var rawItem = command["item"]; file = context.ReplaceVariables(file); JToken item = null; if (set != null) { item = (JToken)context.Fetch(set); } else if (rawItem != null) { item = rawItem; } Console.WriteLine("Saving {0} as {1}", set, file); if (mode == "append") { JSONUtil.AppendToFile(item, file); } else { JSONUtil.WriteFile(item, file); } }
async public void Loaded() { var beforeAppLoadEngine = new CommandEngine<IBeforeAppLoad>(); await beforeAppLoadEngine.Execute(); AppWindowViewModel.SetContent<AppViewModel>(); }
public JObject Prompt(CommandEngine commandEngine) { throw new NotImplementedException(); }
static void Main(string[] args) { CommandEngine.Initialize(); Console.WriteLine("Type help for see all commands"); }
public JObject Prompt(CommandEngine commandEngine) { return(null); }
static void Main(string[] args) { CommandEngine.Start(); }
internal Queryable(CommandEngine commandEngine) { this.commandEngine = commandEngine ?? throw new ArgumentNullException(nameof(commandEngine)); Parameters = new Dictionary <string, DbParameter>(); }
internal HelpCommand(CommandEngine commandEngine) : base("help", "Displays helpt text.") { _commandEngine = commandEngine; }
protected internal void Initiate(CommandEngine commandEngine) { CommandEngine = commandEngine; Attach(this); }
/// <summary> /// Initializes a new instance of the <see cref="CommandConsole"/> class. /// </summary> /// <param name="font"></param> /// <param name="parent">The parent.</param> /// <param name="assemblies">The assemblies containing commands and options to add to this <see cref="CommandConsole"/> instance.</param> /// <param name="game"></param> public CommandConsole(Game game, SpriteFont font, Control parent, params Assembly[] assemblies) : base(parent) { _engine = new CommandEngine(assemblies); _writer = new ConsoleWriter(this); PresentationParameters pp = game.GraphicsDevice.PresentationParameters; SetSize(0, pp.BackBufferHeight / 3); SetPoint(Points.Top, 0, 5); SetPoint(Points.Left, 5, 0); SetPoint(Points.Right, -5, 0); Strata = new ControlStrata() { Layer = Layer.Overlay, Offset = 100 }; FocusPriority = int.MaxValue; LikesHavingFocus = false; IsVisible = false; RespectSafeArea = true; ToggleKey = Keys.Oem8; //var font = Content.Load<SpriteFont>(game, "Consolas"); //skin = Content.Load<Skin>(game, "Console"); //skin.BackgroundColour = new Color(1f, 1f, 1f, 0.8f); _background = new Texture2D(game.GraphicsDevice, 1, 1); _background.SetData(new Color[] { Color.Black }); _textBox = new TextBox(this, game, font, "Command Console", "Enter your command"); _textBox.SetPoint(Points.Bottom, 0, -3); _textBox.SetPoint(Points.Left, 3, 0); _textBox.SetPoint(Points.Right, -3, 0); _textBox.FocusPriority = 1; _textBox.FocusedChanged += c => { if (c.IsFocused) _textBox.BeginTyping(PlayerIndex.One); }; _textBox.IgnoredCharacters.Add('`'); _log = new TextLog(this, font, (int)(3 * Area.Height / (float)font.LineSpacing)); _log.SetPoint(Points.TopLeft, 3, 3); _log.SetPoint(Points.TopRight, -3, 3); _log.SetPoint(Points.Bottom, 0, 0, _textBox, Points.Top); _log.WriteLine("Hello world"); _tabCompletion = new Label(this, font); _tabCompletion.SetSize(300, 0); _tabCompletion.SetPoint(Points.TopLeft, 3, 6, this, Points.BottomLeft); _infoBox = new Label(this, font); _infoBox.SetPoint(Points.TopRight, -3, 6, this, Points.BottomRight); AreaChanged += c => _infoBox.SetSize(Math.Max(0, c.Area.Width - 311), 0); _commandStack = new CommandStack(_textBox, Gestures); BindGestures(); Gestures.BlockedDevices.Add(typeof(KeyboardDevice)); }
public void Execute(CommandEngine engine, ActionConfig action, Dictionary <string, string> args) { }