Exemplo n.º 1
0
        public void ShouldFindTheCommandsInCompositeCommand()
        {
            var somethingAndEditCommand = new SomethingAndEditCommand
            {
                EditCommand      = new EditCommand(),
                SomethingCommand = new SomethingCommand()
            };

            var result = somethingAndEditCommand.GetContainedCommands().ToList();


            result.Should().HaveCount(2);
            result.Should().Contain(c => c.Name == "SomethingCommand" && c.Command is SomethingCommand);
        }
Exemplo n.º 2
0
        public void CompositeCommandsThatFailsShouldBuildCorrectMemberPath()
        {
            var somethingAndEditCommand = new SomethingAndEditCommand
            {
                EditCommand      = new EditCommand(),
                SomethingCommand = new SomethingCommand()
            };

            //Execute command
            var result = Assert.Throws <DomainCommandValidationException>(() => _container.Resolve <ICommandService>().Execute(somethingAndEditCommand));

            //CommandService should now rethrow a DomainCommandValidationException with correct member path
            result.Should().BeOfType <DomainCommandValidationException>();
            result.Message.Should().Be("EditedField is invalid");
            result.InvalidMembers.Should().HaveCount(1);
            result.InvalidMembers.First().Should().Be("EditCommand.EditedField");
        }
Exemplo n.º 3
0
        public void CompositeCommandsThatFailsShouldBuildCorrectMemberPathWhenMultipleFieldAreInvalid()
        {
            var somethingAndEditCommand = new SomethingAndEditCommand
            {
                EditCommand = new EditCommand()
                {
                    BothInvalid = true
                },
                SomethingCommand = new SomethingCommand()
            };

            //Execute command
            var result = Assert.Throws <DomainCommandValidationException>(() => _container.Resolve <ICommandService>().Execute(somethingAndEditCommand));

            result.Message.Should().Be("EditedField and otherfield is invalid");
            result.InvalidMembers.Should().HaveCount(2);
            result.InvalidMembers.First().Should().Be("EditCommand.EditedField");
            result.InvalidMembers.Second().Should().Be("EditCommand.OtherEditedField");
        }