public void SetAlias_Throws_InvalidOperationException_When_Registered() { Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = true; var t = new TestCommand2(); var gc = new GlobalCommand("SomethingTest", "t", Access.Administrator); var added = gc.AddToConsole(); Assert.IsTrue(added); var reg = t.RegisterCommand("SomethingTest"); Assert.IsTrue(reg == RegisterResult.Success); var threw = false; try { t.Alias = "Throws Exception"; } catch (InvalidOperationException) { threw = true; } gc.RemoveFromConsole(); gc.Dispose(); Assert.IsTrue(threw); }
static async Task SendSecondMessagesAsync(int numberOfMessagesToSend) { try { var commander = new Commander(); for (var i = 0; i < numberOfMessagesToSend; i++) { // Create a new message to send to the queue. var command = new TestCommand2("originUser", "SystemX", typeof(Command).FullName, Guid.NewGuid().ToString(), null, Guid.NewGuid().ToString(), "This is the Test Property 2"); // Write the body of the message to the console. Console.WriteLine($"Sending message with ClientId: {command.ClientId} :: {command.TestProperty2}"); // Send the message to the queue. if (UseBinaryFormater) { await commander.SendAsync(command); } else { await commander.SendAsync <ICommand>(command); } } } catch (Exception exception) { Console.WriteLine($"{DateTime.Now} :: Exception: {exception.Message}"); } }
public void CTor_Names_MatchConstructor() { var suffix = "value"; var tc2 = new TestCommand2(suffix); Assert.IsTrue(tc2.Name == "TestCommand2" + suffix); Assert.IsTrue(tc2.Alias == "TC2" + suffix); }
public void SetAlias_SetsAlias_When_NotRegistered() { var t = new TestCommand2(); Assert.IsTrue(t.Name == "TestCommand2"); var expected = "NewAlias"; t.Alias = expected; Assert.IsTrue(t.Alias == expected); }
public void SetName_SetsName_When_NotRegistered() { var t = new TestCommand2(); Assert.IsTrue(t.Name == "TestCommand2"); var expected = "NewName"; t.Name = expected; Assert.IsTrue(t.Name == expected); }
public async Task PostHandleAsync(TestCommand2 command, CancellationToken cancellationToken = default) { var now = _clock.UtcNow; using var tx = _session.BeginTransaction(); var process = await _session.GetAsync <TestProcessEntity>(CorrelationId, cancellationToken); _metricsService.Observe(new MultiStepBusinessProcessMetric("test_process", "process_closed"), (now - process.EventTime).TotalMilliseconds); _metricsService.Observe(new MultiStepBusinessProcessMetric("test_process", "process_overall"), (now - process.StartTime).TotalMilliseconds); _metricsService.Observe(new BusinessProcessHistogram("test_process"), (now - process.StartTime).TotalMilliseconds); await _session.DeleteAsync(process, cancellationToken); await tx.CommitAsync(cancellationToken); }
public void ShouldThrowInvalidOperationExceptionWhenNoCommandHandlerIsRegistered() { List <IQueryHandler> queryHandlers = Enumerable.Repeat <IQueryHandler>(new TestQueryHandler1 <TestQuery1, string>(string.Empty), 1) .ToList(); var mockHandler = new TestCommandHandler1 <TestCommand1>(); ICollection <ICommandHandler> commandHandlers = new List <ICommandHandler> { mockHandler, }; var command = new TestCommand2(); var dispatcher = new CommandAndQueryDispatcher(commandHandlers, queryHandlers); Action action = () => dispatcher.ExecuteCommand(command); action.ShouldThrow <InvalidOperationException>(); }
public void CommandExecute_When_AliasSetManually() { Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = true; var t = new TestCommand2(); t.Alias = "NN"; var gc = new GlobalCommand("SomethingTest", "t", Access.Administrator); var added = gc.AddToConsole(); Assert.IsTrue(added); var reg = t.RegisterCommand("SomethingTest"); Assert.IsTrue(reg == RegisterResult.Success); Crestron.SimplSharp.CrestronConsole.Messages = new StringBuilder(); gc.ExecuteCommand("NN Test"); Assert.IsTrue(Crestron.SimplSharp.CrestronConsole.Messages.ToString().Contains("Default test command executed.")); gc.RemoveFromConsole(); gc.Dispose(); }
public string Handle(TestCommand2 command) { return(command.Value); }
public void OnCommand(TestCommand2 command) { throw new NotImplementedException(); }
//[AccessControl("test-command2")] public async Task TestCommand2Async([FromBody] TestCommand2 command) { await _commandExecutor.ProcessAsync(command, default); }
public void Handle(TestCommand2 command) { }
//[AccessControl("test-command2")] public async Task TestCommand2Async([FromBody] TestCommand2 command) { await _cqrsProcessor.SendAsync(command, default); }