/Source/Bifrost.Specs/Commands/for_CommandContextManager/when_establishing_on_different_threads_with_same_command.cs
C# | 31 lines | 28 code | 3 blank | 0 comment | 0 complexity | e68d4334c552cb74f63e3d7057cb247e MD5 | raw file
Possible License(s): CC-BY-SA-3.0
- using System.Threading;
- using Bifrost.Commands;
- using Machine.Specifications;
-
- namespace Bifrost.Specs.Commands.for_CommandContextManager
- {
- [Subject(Subjects.establishing_context)]
- public class when_establishing_on_different_threads_with_same_command : given.a_command_context_manager
- {
- static ICommandContext firstCommandContext;
- static ICommandContext secondCommandContext;
-
- Establish context = () =>
- {
- var resetEvent = new ManualResetEvent(false);
- var command = new SimpleCommand();
- firstCommandContext = Manager.EstablishForCommand(command);
- var thread = new Thread(
- () =>
- {
- secondCommandContext = Manager.EstablishForCommand(command);
- resetEvent.Reset();
- }
- );
- thread.Start();
- resetEvent.WaitOne(1000);
- };
-
- It should_return_different_contexts = () => firstCommandContext.ShouldNotEqual(secondCommandContext);
- }
- }