Beispiel #1
0
        public void ctor_should_return_valid_instance()
        {
            var message = StartDummySaga.New();
            var sut     = new DefaultMessageContext <StartDummySaga>(message);

            sut.Message.Should().Be(message);
        }
        private async Task <MessageContext> ExecuteCommandAsync(string commandName, string message)
        {
            var services = new ServiceCollection();

            services.AddCommand(builder =>
            {
                builder.AddModule <FooModule>();
            });

            services.AddLocalizations();
            services.AddArgumentWithParsers();

            var provider = services.BuildTestServiceProvider();
            var context  = new DefaultMessageContext
            {
                RequestServices = provider,
                Request         =
                {
                    Message = message
                }
            };

            var commandManager = context.RequestServices.GetRequiredService <ICommandManager>();
            var command        = commandManager.Commands.FirstOrDefault(c => c.Id == commandName);

            Assert.NotNull(command);

            await command.ExecuteAsync(context);

            return(context);
        }