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); }
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"); }
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"); }