public void FunctionalLifeSpanTest_ShouldProduceDesiredResults_ForCommandWithoutResult()
        {
            // Arrange.
            var package = new SimulatedAutofacDependencyPackage();
            var configurationBuilder = new ConfigurationBuilder();
            var configuration        = configurationBuilder.Build();
            var scope           = (IDependencyScope)null;
            var commandMediator = (ICommandMediator)null;
            var command         = new SimulatedCommand();

            using (var engine = package.CreateEngine(configuration))
            {
                // Arrange.
                scope           = engine.Container.CreateScope();
                commandMediator = scope.Resolve <ICommandMediator>();

                using (var target = new SimulatedCommandHandler(commandMediator))
                {
                    // Act.
                    var result = target.Process(command);

                    // Assert.
                    command.IsProcessed.Should().BeTrue();
                    result.Should().BeOfType <Nix>();
                }
            }
        }
Exemple #2
0
        public void ProcessAsync_ShouldProcessCommand_WithoutResult()
        {
            // Arrange.
            var package = new SimulatedAutofacDependencyPackage();
            var configurationBuilder = new ConfigurationBuilder();
            var configuration        = configurationBuilder.Build();
            var scope           = (IDependencyScope)null;
            var commandMediator = (ICommandMediator)null;
            var command         = new SimulatedCommand();

            using (var engine = package.CreateEngine(configuration))
            {
                // Arrange.
                scope           = engine.Container.CreateScope();
                commandMediator = scope.Resolve <ICommandMediator>();

                // Act.
                var task = commandMediator.ProcessAsync(command);
                task.Wait();
                var result = task.Result;

                // Assert.
                command.IsProcessed.Should().BeTrue();
                result.Should().BeOfType <Nix>();
            }
        }