public void ThrowsExpectationExceptionIfExpecatationViolationInBackgroundWhileWaitingForAGivenState()
        {
            IStates threads = mockery.States("threads");

            var blitzer = new Blitzer(5);
            var count = new AtomicInt(5);
            var mock = mockery.NewInstanceOfRole<ISpeaker>();

            Expect.Once.On(mock).Message("Goodbye").Then(threads.Is("finished"));
            OnNewThread(() => blitzer.Blitz(() => {
                                                if (count.Decrement() == 0) mock.Goodbye();
                                                else
                                                    mock.Hello();
                                            }));

            try
            {
                synchronizer.WaitUntil(threads.Is("finished"));
                Assert.Fail("shold have thrown expectation error when unexpected invocation in background");
            }
            catch (ExpectationException e)
            {
                Assert.That(e.Message, NUnit.Framework.Is.StringContaining("Hello()"));
            }
        }
        public void CanWaitUntilStateMachineIsInAGivenState()
        {
            IStates threads = mockery.States("threads");

            var blitzer = new Blitzer(5);
            var count = new AtomicInt(5);
            var mock = mockery.NewInstanceOfRole<ISpeaker>();
            Expect.Exactly(blitzer.TotalActionCount()).On(mock).Message("Hello");
            Expect.Once.On(mock).Message("Goodbye").Then(threads.Is("finished"));
            OnNewThread(() => blitzer.Blitz(() => {
                                                mock.Hello();
                                                if (count.Decrement() == 0) mock.Goodbye();
                                            }));

            synchronizer.WaitUntil(threads.Is("finished"));
            mockery.VerifyAllExpectationsHaveBeenMet();
        }