Ejemplo n.º 1
0
        public void Command_should_create_new_aggregate_root()
        {
            var command = new AggregateRootTargetCreateNewCommand {
                Title = "AggregateRootTargetCreateNewCommand"
            };
            var executor = new TestAttributeMappedCommandExecutor <AggregateRootTarget>(command);

            executor.Execute();

            executor.Instance.Title.Should().Be("AggregateRootTargetCreateNewCommand");
        }
Ejemplo n.º 2
0
        public void Command_should_throw_an_exception_when_the_command_is_not_mapped()
        {
            var command = new AggregateRootTargetNotAMappedCommand {
                Title = "AggregateRootTargetNotAMappedCommand"
            };
            var executor = new TestAttributeMappedCommandExecutor <AggregateRoot>(command);

            Action act = executor.Execute;

            act.ShouldThrow <CommandMappingException>();
        }
Ejemplo n.º 3
0
        public void Command_should_create_new_complex_aggregate_root_using_implicit_parameter_mappings()
        {
            var command = new ComplexAggregateRootTargetCreateNewCommand4 {
                Title = "ComplexAggregateRootTargetCreateNewCommand4", Quantity = 40
            };
            var executor = new TestAttributeMappedCommandExecutor <ComplexAggregateRootTarget>(command);

            executor.Execute();

            executor.Instance.Title.Should().Be("ComplexAggregateRootTargetCreateNewCommand4");
            executor.Instance.Quantity.Should().Be(40);
        }
Ejemplo n.º 4
0
        public void Command_should_update_the_title_of_the_existing_aggregate_root()
        {
            var instance = new AggregateRootTarget("TitleSetInConstructor");
            var command  = new AggregateRootTargetCreateOrUpdateTitleCommand {
                Title = "AggregateRootTargetUpdateTitleCommand"
            };
            var executor = new TestAttributeMappedCommandExecutor <AggregateRootTarget>(command, instance);

            executor.Execute();

            executor.Instance.Title.Should().Be("AggregateRootTargetUpdateTitleCommand");
        }
Ejemplo n.º 5
0
        public void Command_decorated_with_Transactional_attribute_mapped_to_constructor_should_be_executed_in_context_of_transaction()
        {
            bool executedInTransaction = false;
            var  command = new TransactionalAggregateRootTargetCreateNewCommand {
                Title = "TransactionalAggregateRootTargetCreateNewCommand"
            };
            var executor = new TestAttributeMappedCommandExecutor <AggregateRootTarget>(command);

            executor.VerificationAction = () => executedInTransaction = Transaction.Current != null;

            executor.Execute();

            Assert.IsTrue(executedInTransaction);
        }
Ejemplo n.º 6
0
        public void Command_decorated_with_Transactional_attribute_mapped_to_method_should_be_executed_in_context_of_transaction()
        {
            bool executedInTransaction = false;
            var  instance = new AggregateRootTarget("TitleSetInConstructor");
            var  command  = new TransactionalAggregateRootTargetUpdateTitleCommand {
                Title = "TransactionalAggregateRootTargetUpdateTitleCommand"
            };
            var executor = new TestAttributeMappedCommandExecutor <AggregateRootTarget>(command, instance);

            executor.VerificationAction = () => executedInTransaction = Transaction.Current != null;

            executor.Execute();

            Assert.True(executedInTransaction);
        }