-
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 #766 from bnordli/issue/686_part_2a
Ensure Initialize is run only once in CommandHandlerInvoker #686
- Loading branch information
Showing
3 changed files
with
68 additions
and
14 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
36 changes: 36 additions & 0 deletions
36
...st.Specs/Commands/for_CommandHandlerInvoker/when_receiving_asynchronous_initialization.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Threading; | ||
using Bifrost.Commands; | ||
using Machine.Specifications; | ||
using Moq; | ||
using It = Machine.Specifications.It; | ||
|
||
namespace Bifrost.Specs.Commands.for_CommandHandlerInvoker | ||
{ | ||
[Subject(Subjects.handling_commands)] | ||
public class when_receiving_asynchronous_initialization : given.a_command_handler_invoker_with_no_command_handlers | ||
{ | ||
protected static bool result; | ||
|
||
Because of = () => | ||
{ | ||
var command = new Command(); | ||
var thread = new Thread(() => invoker.TryHandle(command)); | ||
|
||
type_discoverer_mock | ||
.Setup(t => t.FindMultiple<IHandleCommands>()) | ||
.Callback( | ||
() => | ||
{ | ||
thread.Start(); | ||
Thread.Sleep(50); | ||
}) | ||
.Returns(new Type[0]); | ||
result = invoker.TryHandle(command); | ||
thread.Join(); | ||
}; | ||
|
||
It should_initialize_only_once = () => | ||
type_discoverer_mock.Verify(m => m.FindMultiple<IHandleCommands>(), 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