示例#1
0
        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);
        }
示例#2
0
        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}");
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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>();
            }
示例#8
0
        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();
        }
示例#9
0
 public string Handle(TestCommand2 command)
 {
     return(command.Value);
 }
示例#10
0
 public void OnCommand(TestCommand2 command)
 {
     throw new NotImplementedException();
 }
示例#11
0
 //[AccessControl("test-command2")]
 public async Task TestCommand2Async([FromBody] TestCommand2 command)
 {
     await _commandExecutor.ProcessAsync(command, default);
 }
示例#12
0
 public void Handle(TestCommand2 command)
 {
 }
示例#13
0
 //[AccessControl("test-command2")]
 public async Task TestCommand2Async([FromBody] TestCommand2 command)
 {
     await _cqrsProcessor.SendAsync(command, default);
 }