-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from bnordli/issue/686_part_2b
Issue/686 part 2b
- Loading branch information
Showing
28 changed files
with
295 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 23 additions & 21 deletions
44
Source/Bifrost.Specs/Commands/for_CommandCoordinator/when_handling_an_invalid_command.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
using Bifrost.Commands; | ||
using Machine.Specifications; | ||
using Bifrost.Validation; | ||
using Machine.Specifications; | ||
using Moq; | ||
using It = Machine.Specifications.It; | ||
|
||
namespace Bifrost.Specs.Commands.for_CommandCoordinator | ||
{ | ||
[Subject(typeof(CommandCoordinator))] | ||
public class when_handling_an_invalid_command : given.a_command_coordinator | ||
{ | ||
static CommandResult Result; | ||
static CommandResult result; | ||
static CommandValidationResult validation_errors; | ||
|
||
Establish context = () => | ||
{ | ||
validation_errors = new CommandValidationResult | ||
{ | ||
ValidationResults = new ValidationResult[] | ||
{ | ||
new ValidationResult("First validation failure"), | ||
new ValidationResult("Second validation failure") | ||
} | ||
}; | ||
{ | ||
validation_errors = new CommandValidationResult | ||
{ | ||
ValidationResults = new[] | ||
{ | ||
new ValidationResult("First validation failure"), | ||
new ValidationResult("Second validation failure") | ||
} | ||
}; | ||
|
||
command_validators_mock.Setup(cvs => cvs.Validate(command_mock.Object)).Returns( | ||
validation_errors); | ||
}; | ||
command_validators_mock | ||
.Setup(cvs => cvs.Validate(command)) | ||
.Returns(validation_errors); | ||
}; | ||
|
||
Because of = () => Result = coordinator.Handle(command_mock.Object); | ||
|
||
Because of = () => result = coordinator.Handle(command); | ||
|
||
It should_have_validated_the_command = () => command_validators_mock.VerifyAll(); | ||
It should_have_a_result = () => Result.ShouldNotBeNull(); | ||
It should_have_success_set_to_false = () => Result.Success.ShouldBeFalse(); | ||
It should_have_a_record_of_each_validation_failure = () => Result.ValidationResults.ShouldContainOnly(validation_errors.ValidationResults); | ||
It should_not_handle_the_command = () => command_handler_manager_mock.Verify(chm => chm.Handle(command_mock.Object), Moq.Times.Never()); | ||
It should_rollback_the_command_context = () => command_context_mock.Verify(c => c.Rollback(), Moq.Times.Once()); | ||
It should_have_a_result = () => result.ShouldNotBeNull(); | ||
It should_have_success_set_to_false = () => result.Success.ShouldBeFalse(); | ||
It should_have_a_record_of_each_validation_failure = () => result.ValidationResults.ShouldContainOnly(validation_errors.ValidationResults); | ||
It should_not_handle_the_command = () => command_handler_manager_mock.Verify(chm => chm.Handle(command), Times.Never()); | ||
It should_rollback_the_command_context = () => command_context_mock.Verify(c => c.Rollback(), Times.Once()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 6 additions & 14 deletions
20
Source/Bifrost.Specs/Commands/for_CommandCoordinator/when_handling_command_with_success.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,20 @@ | ||
using Bifrost.Commands; | ||
using Machine.Specifications; | ||
using It = Machine.Specifications.It; | ||
using Bifrost.Validation; | ||
|
||
namespace Bifrost.Specs.Commands.for_CommandCoordinator | ||
{ | ||
[Subject(typeof(CommandCoordinator))] | ||
public class when_handling_command_with_success : given.a_command_coordinator | ||
{ | ||
static CommandResult Result; | ||
static CommandResult result; | ||
|
||
Establish context = () => | ||
{ | ||
var validation_results = new CommandValidationResult(); | ||
command_validators_mock.Setup(cvs => cvs.Validate(command_mock.Object)).Returns(validation_results); | ||
}; | ||
command_validators_mock.Setup(cvs => cvs.Validate(command)).Returns(new CommandValidationResult()); | ||
|
||
Because of = () => | ||
{ | ||
Result = coordinator.Handle(command_mock.Object); | ||
}; | ||
Because of = () => result = coordinator.Handle(command); | ||
|
||
It should_have_validated_the_command = () => command_validators_mock.VerifyAll(); | ||
It should_have_a_result = () => Result.ShouldNotBeNull(); | ||
It should_have_success_set_to_true = () => Result.Success.ShouldBeTrue(); | ||
It should_have_a_result = () => result.ShouldNotBeNull(); | ||
It should_have_success_set_to_true = () => result.Success.ShouldBeTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.