public void CreateNewCommandFromCommandSourceWithNoMutator() { var source = new EmptyCommand { Id = Guid.NewGuid(), CorrelationId = "ABC123", CurrentUser = "******", OccurredTimeUtc = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)) }; var created = source.CreateNewCommand <EmptyCommand>(); created.Should().NotBeNull("because the created instance should exist"); // Verify new values are populated. created.Id.Should().NotBe(source.Id, "because the id should be a new value"); created.Id.Should().NotBe(default(Guid), "because the id should be populated"); created.OccurredTimeUtc.Should().NotBe(source.OccurredTimeUtc, "because the occurred time should be a new value"); created.OccurredTimeUtc.Should().NotBe(default(DateTime), "because the occurred time should be populated"); // Verify copied values are copied. created.CorrelationId.Should().Be(source.CorrelationId, "because the correlation identifier should be copied"); created.CurrentUser.Should().Be(source.CurrentUser, "because the current user should be copied"); }
public MultiPult() { _buttons = new ICommand[2]; for (var i = 0; i < _buttons.Length; i++) { _buttons[i] = new EmptyCommand(); } _commandsHistory = new Stack <ICommand>(); }
public RemoteControl() { for (var i = 0; i < 5; i++) { onSlots[i] = new EmptyCommand(); offSlots[i] = new EmptyCommand(); undoCommand = new EmptyCommand(); } }
public void should_create_message_dispatch_for_empty_message() { var command = new EmptyCommand(); var transportMessage = command.ToTransportMessage(); transportMessage.Content = Stream.Null; var dispatch = _bus.CreateMessageDispatch(transportMessage); dispatch.Message.ShouldEqualDeeply(command); }
public IUndoableCommand Pop() { if (_commands.First != null) { IUndoableCommand first = _commands.First.Value; _commands.RemoveFirst(); return(first); } return(EmptyCommand.GetEmptyCommand()); }
public void Write() { Command command = new EmptyCommand(); var context = new Context(); var writer = new StringWriter(); context.Output = writer; command.Context = context; command.Execute(); var expected = string.Format("12{0}3{0}", Environment.NewLine); Assert.AreEqual(expected, writer.ToString()); }
protected override async Task <List <CurrencyView> > CommandExecute(EmptyCommand command) { List <CurrencyView> views = null; var currencies = await _context.Currencies.ToListAsync(); if (currencies != null) { views = _mapper.Map <List <CurrencyView> >(currencies); } return(views); }
/// <summary> /// Give the number of the devices to be controlled as a parameter to the constructor. /// </summary> /// <param name="numberOfDevicesToBeControlled"></param> public RemoteControl(int numberOfDevicesToBeControlled) { OnCommands = new Command[numberOfDevicesToBeControlled]; OffCommands = new Command[numberOfDevicesToBeControlled]; Command emptyCommand = new EmptyCommand(); // Initialize all the command slots with an empty command. for (int i = 0; i < numberOfDevicesToBeControlled; i++) { SetCommand(i, emptyCommand, emptyCommand); } }
public static int Main(string[] args) { var app = new CommandLineApplication { Name = "Geek Cafe AWS CDK DevOps CLI", Description = "Wrapper for AWS CDK" }; var options = new Commands.Options.Common(); options.Register(app, ""); // register the commands app.RegisterCommands(); // app.OnExecute(() => { // if we get here then a registered command wasn't found // so we can run the default var cmd = new EmptyCommand(options); var result = cmd.Execute(); if (result == (int)ExitCodes.MISSING_OPTIONS) { app.ShowHelp(); } return(result); }); var exitCode = 0; try { // attempt to execute a command based on what we registred above Utilities.Logger.Log($"{app.Name} starting exection."); exitCode = app.Execute(args); Utilities.Logger.Log($"{app.Name} executed successfully."); } catch (Exception ex) { // something bad happened Utilities.Logger.Log($"{app.Name} executed with errors."); Utilities.Logger.Log($"Fatel Exception {ex.Message}"); exitCode = (int)ExitCodes.FATEL_ERROR; } return(exitCode); }
public void should_dispatch_received_empty_message() { var command = new EmptyCommand(); var invokerCalled = false; SetupDispatch(command, _ => invokerCalled = true); var transportMessageReceived = command.ToTransportMessage(_peerUp); transportMessageReceived.Content = Stream.Null; _transport.RaiseMessageReceived(transportMessageReceived); invokerCalled.ShouldBeTrue(); }
public void Command() { var command = new EmptyCommand(); var step = Step.Create("CommandAsync", async context => { await _commandBus.SendAsync(command); return(Response.Ok()); }); var scenario = CreateScenario("Command performance", new[] { step }); NBomberRunner.RegisterScenarios(scenario).RunTest(); }
public void Digger_name_that_doesnt_exist_is_invalid() { var command = new EmptyCommand { GameState = gameState, DiggerName = MISSING_DIGGER_NAME }; commandHandler.Handle(command); var output = ConsoleBufferHelper.GetText(proc.Output); output.ShouldBe($"Could not find digger named {MISSING_DIGGER_NAME}"); }
public void TestInit() { _context = new ExecutionContextMock(); _testCommand = new EmptyCommand(); _testCommand.UserInfo = new UserInfoEmbedded { MessageGuid = "guid", MessageText = "text" }; Logging.Logging log = new Logging.Logging(); _logger = new ExecutionLoggerMock(); log.AddLogger(_logger); _context.Log = log; }
protected override async Task <List <ExchangePairView> > CommandExecute(EmptyCommand command) { List <ExchangePairView> views = null; var entities = await _context.Pairs .Include(x => x.CurrencyFrom) .Include(x => x.CurrencyTo) .Include(x => x.Exchange) .ToListAsync(); if (entities != null) { views = _mapper.Map <List <ExchangePairView> >(entities); } return(views); }
public Input(Bank bank, ConsoleMessage message) { _currentState = new CurrentState(); _preparedCommands = new Dictionary <string, Command> { ["accounts"] = new GetAccountsCommand(bank, _currentState, message), ["open"] = new OpenAccountCommand(bank, _currentState, message), ["transfer"] = new TransferCommand(bank, _currentState, message), ["close"] = new CloseAccountCommand(bank, _currentState, message), ["undo"] = new UndoCommand(bank, _currentState, message), ["abort"] = new AbortCommand(bank, _currentState, message) }; _emptyCommand = new EmptyCommand(bank, _currentState, message); }
public void ClearTest() { var light = new Light(); var command0 = new OnCommand(light); var command1 = new OnCommand(light); var command2 = new OnCommand(light); var command3 = new OnCommand(light); _undoStack.Push(command0); _undoStack.Push(command1); _undoStack.Push(command2); _undoStack.Push(command3); _undoStack.Clear(); var ret = _undoStack.Pop(); Assert.AreEqual(ret, EmptyCommand.GetEmptyCommand()); }
public void AbilitiesInitialized(List <Ability> abilities) { if (maxAllowedAbilityNumber < abilities.Count) { Debug.Log("Error in ability count!"); } abilityCommands = new Command[maxAllowedAbilityNumber]; for (int i = 0; i < maxAllowedAbilityNumber; i++) { if (i >= abilities.Count) { abilityCommands[i] = new EmptyCommand(); } else { abilityCommands[i] = new AbilityCommand(abilities[i].abilityData.abilityName); } } }
public void should_read_empty_message() { var transportMessage = new EmptyCommand().ToTransportMessage(); var outputStream = new CodedOutputStream(); outputStream.WriteTransportMessage(transportMessage); var inputStream = new CodedInputStream(outputStream.Buffer, 0, outputStream.Position); var deserialized = inputStream.ReadTransportMessage(); deserialized.Id.ShouldEqual(transportMessage.Id); deserialized.MessageTypeId.ShouldEqual(transportMessage.MessageTypeId); deserialized.Content.ShouldEqual(Stream.Null); deserialized.Originator.ShouldEqualDeeply(transportMessage.Originator); deserialized.Environment.ShouldEqual(transportMessage.Environment); deserialized.WasPersisted.ShouldEqual(transportMessage.WasPersisted); var deserializedMessage = deserialized.ToMessage() as EmptyCommand; deserializedMessage.ShouldNotBeNull(); }
/// <summary> /// Executes commands from the console. /// </summary> /// <param name="input">The string containing the command and parameters.</param> /// <returns>Returns the execution results or error messages.</returns> public void Execute(string input) { if (input == "undo") { Unexecute(); return; } else if (input == "redo") { Reexecute(); return; } bool UnrecognizedCommand = false; string[] arguments = input.Split(new Char[] { ' ' }); ICommand cmd; if (!CommandHandlers.ContainsKey(arguments[0])) { cmd = new EmptyCommand(); UnrecognizedCommand = true; } else { cmd = CommandHandlers[arguments[0]](); } if (!UnrecognizedCommand) { UndoneCommands.Clear(); } if (cmd.Execute(arguments)) { Commands.Push(cmd); } Console.WriteLine(cmd.getOutput()); Console.Prompt(Prompt, Execute); }
public void should_read_empty_message() { var transportMessage = new EmptyCommand().ToTransportMessage(); var bufferWriter = new ProtoBufferWriter(); bufferWriter.WriteTransportMessage(transportMessage); var bufferReader = new ProtoBufferReader(bufferWriter.Buffer, bufferWriter.Position); var deserialized = bufferReader.ReadTransportMessage(); deserialized.Id.ShouldEqual(transportMessage.Id); deserialized.MessageTypeId.ShouldEqual(transportMessage.MessageTypeId); deserialized.Content.ShouldEqual(Stream.Null); deserialized.Originator.ShouldEqualDeeply(transportMessage.Originator); deserialized.Environment.ShouldEqual(transportMessage.Environment); deserialized.WasPersisted.ShouldEqual(transportMessage.WasPersisted); var deserializedMessage = deserialized.ToMessage() as EmptyCommand; deserializedMessage.ShouldNotBeNull(); }
public void PushPopTest() { var light = new Light(); var command0 = new OnCommand(light); var command1 = new OnCommand(light); var command2 = new OnCommand(light); var command3 = new OnCommand(light); _undoStack.Push(command0); _undoStack.Push(command1); _undoStack.Push(command2); _undoStack.Push(command3); var retCommand3 = _undoStack.Pop(); var retCommand2 = _undoStack.Pop(); var retCommand1 = _undoStack.Pop(); var retCommand0 = _undoStack.Pop(); Assert.AreEqual(retCommand0, EmptyCommand.GetEmptyCommand()); Assert.AreEqual(command1, retCommand1); Assert.AreEqual(command2, retCommand2); Assert.AreEqual(command3, retCommand3); }
public void DecodeMessage(string s) { if (_cl != null) { if (s.Length > 5) { PlayerCommandsData playerData = JsonConvert.DeserializeObject <PlayerCommandsData>(s); if (playerData.commands != null) { for (int i = 0; i < playerData.commands.Count; i++) { int type = int.Parse(playerData.commands[i][0].ToString()); string lCommand = playerData.commands[i].Remove(0, 1); print(playerData.commands[i]); switch (type) { case 0: AttackCommand c = JsonConvert.DeserializeObject <AttackCommand>(lCommand); ServiceLocator.GetService <CommandManager>().allCommands.Add(c); break; case 1: BuildCommand bc = JsonConvert.DeserializeObject <BuildCommand>(lCommand); ServiceLocator.GetService <CommandManager>().allCommands.Add(bc); print(ServiceLocator.GetService <CommandManager>().allCommands.Count); break; case 2: HireCommand hc = JsonConvert.DeserializeObject <HireCommand>(lCommand); ServiceLocator.GetService <CommandManager>().allCommands.Add(hc); break; case 3: PauseCommand pc = JsonConvert.DeserializeObject <PauseCommand>(lCommand); ServiceLocator.GetService <CommandManager>().allCommands.Add(pc); break; case 4: MoveCommand mc = JsonConvert.DeserializeObject <MoveCommand>(lCommand); ServiceLocator.GetService <CommandManager>().allCommands.Add(mc); break; case 5: EmptyCommand ec = JsonConvert.DeserializeObject <EmptyCommand>(lCommand); ServiceLocator.GetService <CommandManager>().allCommands.Add(ec); break; } //Command c = (Command)JsonConvert.DeserializeObject(playerData.commands[i], // CommandManager.commandTypes[type].GetType()); } ProccessedCommands(); } } else { //TODO: change message checks if (s == "inc") { turnData = ServiceLocator.GetService <CommandManager>().CreateTurnData(turn + 2, _playerRef.id); string msg = JsonConvert.SerializeObject(turnData); _cl.SendMessage(msg); turn++; } else if (s == "0") { _playerRef.id = 0; } else if (s == "1") { _playerRef.id = 1; } else { } } } }
public Void VisitEmptyCommand(EmptyCommand ast, Frame frame) { return(null); }
/// <summary> /// Creates a command according to the user input /// </summary> /// <param name="command">Command to be created</param> /// <returns>The created command</returns> public ICommand GetCommand(string command) { if (!this.CommandsList.ContainsKey(command)) { ICommand commandExecutor = null; switch (command) { case "help": { commandExecutor = new CheatCommand(this.Data, this.Notifier, this.NumberGenerator); break; } case "start": { commandExecutor = new InitializeGameCommand(this.Data, this.Notifier, this.NumberGenerator); break; } case "commands": { commandExecutor = new DisplayCommandsListCommand(this.Notifier); break; } case "top": { commandExecutor = new DisplayScoreboardCommand(this.Scoreboard); break; } case "quit": { commandExecutor = new QuitGameCommand(this.Notifier); break; } case "exit": { commandExecutor = new ExitGameCommand(this.Notifier); break; } case "empty": { commandExecutor = new EmptyCommand(); break; } default: { commandExecutor = this.ProcessGuessAndReturnAppropriateCommand(command); break; } } this.CommandsList.Add(command, commandExecutor); return commandExecutor; } else { return this.CommandsList[command]; } }
public void CommandExecute(EmptyCommand c) { Debug.Log(c.ToString()); }
public void CommandToString() { Command command = new EmptyCommand(); Assert.AreEqual("empty", command.ToString()); }
public void Execute() { Command command = new EmptyCommand(); Assert.AreEqual(0, command.Execute()); }
public Void VisitEmptyCommand(EmptyCommand ast, Void arg) { return(null); }
public void TestInit() { _context = new ExecutionContextMock(); _testCommand = new EmptyCommand(); _testCommand.UserInfo = new UserInfoEmbedded { MessageGuid = "guid", MessageText = "text" }; Logging.Logging log = new Logging.Logging(); _logger = new ExecutionLoggerMock(); log.AddLogger(_logger); _context.Log = log; }
public void CommandWithNoParamaters_AndEmptyParameters() { ICommand command = new EmptyCommand(); classUnderTest.Hydrate(ref command, new object()); }