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

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

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

                    // Assert.
                    command.IsProcessed.Should().BeTrue();
                    result.Should().Be(command.Identifier);
                }
            }
        }
Ejemplo n.º 2
0
        public void ProcessAsync_ShouldProcessCommand_WithResult()
        {
            // Arrange.
            var package = new SimulatedAutofacDependencyPackage();
            var configurationBuilder = new ConfigurationBuilder();
            var configuration        = configurationBuilder.Build();
            var scope           = (IDependencyScope)null;
            var commandMediator = (ICommandMediator)null;
            var command         = new SimulatedCommandWithResult();

            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().Be(command.Identifier);
            }
        }