public void IProviderMethodsPassThroughAdapter()
        {
            MockRepository mocks = new MockRepository();
            IRasterProvider adapted = mocks.CreateMock<IRasterProvider>();
            ICoordinateTransformation transformStub =
                MockRepository.GenerateStub<ICoordinateTransformation>();
            Expression queryStub =
                MockRepository.GenerateStub<Expression>();
            Object objectStub =
                MockRepository.GenerateStub<Object>();
            IExtents extentsStub =
                MockRepository.GenerateStub<IExtents>();
            ICoordinateSystem coordinateSystemStub =
                MockRepository.GenerateStub<ICoordinateSystem>();

            using (mocks.Unordered())
            {
                adapted.Close();
                Expect.Call(adapted.ConnectionId)
                    .Return("connectionid");
                adapted.CoordinateTransformation = transformStub;
                Expect.Call(adapted.CoordinateTransformation)
                    .Return(transformStub);
                Expect.Call(adapted.ExecuteQuery(queryStub))
                    .Return(objectStub);
                Expect.Call(adapted.GetExtents())
                    .Return(extentsStub);
                Expect.Call(adapted.IsOpen)
                    .Return(true);
                adapted.Open();
                Expect.Call(adapted.SpatialReference)
                    .Return(coordinateSystemStub);
                //adapted.Srid = 1;
                Expect.Call(adapted.Srid)
                    .Return("2");
            }

            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            adapter.Close();
            Assert.Equal("connectionid", adapter.ConnectionId);
            adapter.CoordinateTransformation = transformStub;
            Assert.Same(transformStub, adapter.CoordinateTransformation);
            Assert.Same(objectStub, adapter.ExecuteQuery(queryStub));
            Assert.Same(extentsStub, adapter.GetExtents());
            Assert.True(adapter.IsOpen);
            adapter.Open();
            Assert.Same(coordinateSystemStub, adapter.SpatialReference);
            //adapter.Srid = 1;
            Assert.Equal("2", adapter.Srid);

            mocks.VerifyAll();
        }
        public void HttpRequestResponse_Construction_With_Non_Timeout_Stream_When_Specifying_Timeout_Test()
        {
            MockRepository mocks = new MockRepository();

            Stream s = mocks.CreateMock<Stream>();
            using(mocks.Unordered()) {
                Expect.Call(s.CanTimeout).Return(false);
            }
            mocks.ReplayAll();

            HttpRequestResponse httpRequestResponse = new HttpRequestResponse(s, null, null, 400);
        }
Ejemplo n.º 3
0
        public void FlushResponse_Is_Not_Final_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();

            using (mocks.Unordered()) {
                Expect.Call(request.RawUrl).Return("/test/").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
                Expect.Call(delegate { response.Flush(); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            aspNetWorker.FlushResponse(false);
        }
        public void IFeatureProviderMethodsPassThroughAdapter()
        {
            MockRepository mocks = new MockRepository();
            IFeatureProvider adapted = mocks.CreateMock<IFeatureProvider>();
            IGeometryFactory iGeometryFactoryStub =
                MockRepository.GenerateStub<IGeometryFactory>();
            FeatureDataTable featureDataTableStub =
                MockRepository.GenerateStub<FeatureDataTable>(iGeometryFactoryStub);
            IFeatureDataReader iFeatureDataReaderStub =
                MockRepository.GenerateStub<IFeatureDataReader>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub<IExtents>();
            FeatureQueryExpression featureQueryExpressionStub =
                MockRepository.GenerateStub<FeatureQueryExpression>(iExtentsStub, SpatialOperation.Intersects);
            FeatureQueryExecutionOptions featureQueryExecutionOptionsStub =
                new FeatureQueryExecutionOptions();
            DataTable dataTableStub =
                MockRepository.GenerateStub<DataTable>();
            CultureInfo cultureInfoStub =
                MockRepository.GenerateStub<CultureInfo>(1);

            using (mocks.Unordered())
            {
                Expect.Call(adapted.CreateNewTable())
                    .Return(featureDataTableStub);
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub, featureQueryExecutionOptionsStub))
                    .Return(iFeatureDataReaderStub);
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub))
                    .Return(iFeatureDataReaderStub);
                adapted.GeometryFactory = iGeometryFactoryStub;
                Expect.Call(adapted.GeometryFactory)
                    .Return(iGeometryFactoryStub);
                Expect.Call(adapted.GetFeatureCount())
                    .Return(3);
                Expect.Call(adapted.GetSchemaTable())
                    .Return(dataTableStub);
                Expect.Call(adapted.Locale)
                    .Return(cultureInfoStub);
                adapted.SetTableSchema(featureDataTableStub);
            }
            mocks.ReplayAll();

            AsyncFeatureProviderAdapter adapter = new AsyncFeatureProviderAdapter(adapted);
            Assert.Same(featureDataTableStub, adapter.CreateNewTable());
            Assert.Same(iFeatureDataReaderStub,
                adapter.ExecuteFeatureQuery(featureQueryExpressionStub, featureQueryExecutionOptionsStub));
            Assert.Same(iFeatureDataReaderStub,
                adapter.ExecuteFeatureQuery(featureQueryExpressionStub));
            adapter.GeometryFactory = iGeometryFactoryStub;
            Assert.Same(iGeometryFactoryStub, adapter.GeometryFactory);
            Assert.Equal(3, adapter.GetFeatureCount());
            Assert.Same(dataTableStub, adapter.GetSchemaTable());
            Assert.Same(cultureInfoStub, adapter.Locale);
            adapter.SetTableSchema(featureDataTableStub);

            mocks.VerifyAll();
        }
        public void EndExecuteQueryThrowsTerminatingException()
        {
            MockRepository mocks = new MockRepository();
            IRasterProvider adapted = mocks.CreateMock<IRasterProvider>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub<IExtents>();
            RasterQueryExpression RasterQueryExpressionStub =
                MockRepository.GenerateStub<RasterQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteRasterQuery(RasterQueryExpressionStub))
                    .Do(new ExecuteQueryDelegate(executeQueryExceptionMock));
            }
            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(RasterQueryExpressionStub, null);

            Assert.NotNull(ar);

            Assert.Throws<InvalidOperationException>(delegate { adapter.EndExecuteQuery(ar); });
        }
        public void BeginExecuteQueryBlockUntilDone()
        {
            MockRepository mocks = new MockRepository();
            IRasterProvider adapted = mocks.CreateMock<IRasterProvider>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub<IExtents>();
            RasterQueryExpression RasterQueryExpressionStub =
                MockRepository.GenerateStub<RasterQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            _returnStreamStub = MockRepository.GenerateStub<Stream>();
            _sleepInterval = 750;

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteRasterQuery(RasterQueryExpressionStub))
                    .Do(new ExecuteQueryDelegate(executeQueryMock));
            }
            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(RasterQueryExpressionStub, null);

            Assert.NotNull(ar);

            Stopwatch timer = Stopwatch.StartNew();
            Assert.Same(_returnStreamStub, adapter.EndExecuteQuery(ar));
            timer.Stop();

            Assert.True(ar.IsCompleted);
            Assert.False(ar.CompletedSynchronously);
            Assert.True(timer.ElapsedMilliseconds > 500L);

            mocks.VerifyAll();
        }
        public void BeginExecuteQueryPollingNotification()
        {
            MockRepository mocks = new MockRepository();
            IRasterProvider adapted = mocks.CreateMock<IRasterProvider>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub<IExtents>();
            RasterQueryExpression RasterQueryExpressionStub =
                MockRepository.GenerateStub<RasterQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            _returnStreamStub = MockRepository.GenerateStub<Stream>();
            _sleepInterval = 1000;

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteRasterQuery(RasterQueryExpressionStub))
                    .Do(new ExecuteQueryDelegate(executeQueryMock));
            }
            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(RasterQueryExpressionStub, null);

            Assert.NotNull(ar);
            Assert.False(ar.IsCompleted);
            while (!ar.IsCompleted)
            {
                Thread.Sleep(350);
            }

            Assert.True(ar.IsCompleted);
            Assert.Same(_returnStreamStub, adapter.EndExecuteQuery(ar));

            mocks.VerifyAll();
        }
        public void IRasterProviderMethodsPassThroughAdapter()
        {
            MockRepository mocks = new MockRepository();
            IRasterProvider adapted = mocks.CreateMock<IRasterProvider>();
            Stream streamStub =
                MockRepository.GenerateStub<Stream>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub<IExtents>();
            RasterQueryExpression rasterQueryExpressionStub =
                MockRepository.GenerateStub<RasterQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteRasterQuery(rasterQueryExpressionStub))
                    .Return(streamStub);
            }
            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            Assert.Same(streamStub, adapter.ExecuteRasterQuery(rasterQueryExpressionStub));

            mocks.VerifyAll();
        }
        public void IDisposableMethodsPassThroughAdapter()
        {
            MockRepository mocks = new MockRepository();
            IRasterProvider adapted = mocks.CreateMock<IRasterProvider>();

            using (mocks.Unordered())
            {
                adapted.Dispose();
            }
            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            adapter.Dispose();

            mocks.VerifyAll();
        }
Ejemplo n.º 10
0
        public void GetHttpVerbName_When_Is_Put_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();

            using (mocks.Unordered()) {
                Expect.Call(request.RawUrl).Return("/foo/").Repeat.Any();
                Expect.Call(request.HttpMethod).Return("PUT").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/foo", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            Assert.AreEqual("PUT", aspNetWorker.GetHttpVerbName());
        }
        public void MovingFundsUsingTransactions()
        {
            MockRepository mocks = new MockRepository();
            IDatabaseManager databaseManager = mocks.StrictMock<IDatabaseManager>();
            IBankAccount accountOne = mocks.StrictMock<IBankAccount>(),
                         accountTwo = mocks.StrictMock<IBankAccount>();

            using (mocks.Ordered())
            {
                Expect.Call(databaseManager.BeginTransaction()).Return(databaseManager);
                using (mocks.Unordered())
                {
                    Expect.Call(accountOne.Withdraw(1000));
                    Expect.Call(accountTwo.Deposit(1000));
                }
                databaseManager.Dispose();
            }

            mocks.ReplayAll();

            Bank bank = new Bank(databaseManager);
            bank.TransferFunds(accountOne, accountTwo, 1000);

            mocks.VerifyAll();
        }
        public void MakeSurePrototypeTargetIsNotNeedlesslyCreatedDuringInitialization_Unit()
        {
            GoodCommand target = new GoodCommand();
            NopInterceptor advice = new NopInterceptor();

            MockRepository mocks = new MockRepository();
            IObjectFactory factory = (IObjectFactory) mocks.CreateMock(typeof(IObjectFactory));

            ProxyFactoryObject fac = new ProxyFactoryObject();
            fac.ProxyInterfaces = new string[] { typeof(ICommand).FullName };
            fac.IsSingleton = false;
            fac.InterceptorNames = new string[] { "advice", "prototype" };
            fac.ObjectFactory = factory;

            //            using (mocks.Record())
            {
                using (mocks.Unordered())
                {
                    Expect.Call(factory.IsSingleton("advice")).Return(true);
                    Expect.Call(factory.GetObject("advice")).Return(advice);
                    Expect.Call(factory.GetType("prototype")).Return(target.GetType());
                    Expect.Call(factory.GetObject("prototype")).Return(target);
                }
            }
            mocks.ReplayAll();

            //            using(mocks.Playback())
            {
                fac.GetObject();
            }
            mocks.VerifyAll();
        }
Ejemplo n.º 13
0
        public void GetProtocol_When_Request_Is_Secure_And_Response_Is_Not_Secure_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();

            using (mocks.Unordered()) {
                Expect.Call(response.IsSecure).Return(false).Repeat.Any();
                Expect.Call(request.IsSecure).Return(true).Repeat.Any();
                Expect.Call(request.RawUrl).Return("/test/").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            Assert.AreEqual("HTTP", aspNetWorker.GetProtocol());
        }
Ejemplo n.º 14
0
        public void GetPreloadedEntityBody_When_No_Data_Loaded_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();
            byte[] postData = new byte[] { };

            using (mocks.Unordered()) {
                Expect.Call(request.PostData).Return(postData).Repeat.Any();
                Expect.Call(request.RawUrl).Return("/test/").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            Assert.AreEqual(postData, aspNetWorker.GetPreloadedEntityBody());
        }
Ejemplo n.º 15
0
        public void GetPathInfo_With_Tail_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();

            using (mocks.Unordered()) {
                Expect.Call(request.RawUrl).Return("/foo/Page.aspx/ATail").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/foo", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            Assert.AreEqual("/ATail", aspNetWorker.GetPathInfo());
        }
Ejemplo n.º 16
0
        public void GetLocalPort_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();
            IPEndPoint ipEndPoint = new IPEndPoint(new IPAddress(new byte[] { 47, 94, 23, 12 }), 1238);

            using (mocks.Unordered()) {
                Expect.Call(request.RawUrl).Return("/foo/").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(request.LocalEndPoint).Return(ipEndPoint).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/foo", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            Assert.AreEqual(ipEndPoint.Port, aspNetWorker.GetLocalPort());
        }
Ejemplo n.º 17
0
        public void GetKnownRequestHeader_Test()
        {
            MockRepository mocks = new MockRepository();
            IAspNetRuntime aspNetRuntime = mocks.CreateMock<IAspNetRuntime>();
            ITransaction transaction = mocks.CreateMock<ITransaction>();
            IResponse response = mocks.CreateMock<IResponse>();
            IRequest request = mocks.CreateMock<IRequest>();
            string expectedValue = (new Guid()).ToString();
            int index = (new Random()).Next();

            using (mocks.Unordered()) {
                Expect.Call(request.RawUrl).Return("/foo/").Repeat.Any();
                Expect.Call(transaction.Request).Return(request).Repeat.Any();
                Expect.Call(transaction.Response).Return(response).Repeat.Any();
                Expect.Call(request.GetKnownRequestHeader(index)).Return(expectedValue).Repeat.Any();
                Expect.Call(delegate { aspNetRuntime.ProcessRequest(null); }).IgnoreArguments();
            }
            mocks.ReplayAll();

            AspNetWorker aspNetWorker = new AspNetWorker(aspNetRuntime, "/foo", @"c:\temp");

            aspNetWorker.ProcessTransaction(transaction);
            Assert.AreEqual(expectedValue, aspNetWorker.GetKnownRequestHeader(index));
        }
Ejemplo n.º 18
0
 public void MovingFundsUsingTransaction()
 {
     //Arrange
     var mocks = new MockRepository();
     IDatabaseMapper databaseMapper = mocks.StrictMock<IDatabaseMapper>();
     IBankAccount account1 = mocks.StrictMock<IBankAccount>();
     IBankAccount account2 = mocks.StrictMock<IBankAccount>();
     using (mocks.Ordered())
     {
         Expect.Call(databaseMapper.BeginTransaction()).Return(databaseMapper);
         using (mocks.Unordered())
         {
             account1.Withdraw(1000);
             account2.Deposit(1000);
         }
         databaseMapper.Dispose();
     }
     mocks.ReplayAll();
     //Act
     Bank bank = new Bank(databaseMapper);
     bank.TransferFunds(account1, account2, 1000);
     //Assert
     mocks.VerifyAll();
 }
        public void BeginExecuteQueryCallBackNotification()
        {
            CallBackHelper callBackRecorder = new CallBackHelper();

            MockRepository mocks = new MockRepository();
            IFeatureProvider adapted = mocks.CreateMock<IFeatureProvider>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub<IExtents>();
            FeatureQueryExpression featureQueryExpressionStub =
                MockRepository.GenerateStub<FeatureQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            _returnReaderStub = MockRepository.GenerateStub<IFeatureDataReader>();
            _sleepInterval = 500;

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub))
                    .Do(new ExecuteQueryDelegate(executeQueryMock));
            }
            mocks.ReplayAll();

            AsyncFeatureProviderAdapter adapter = new AsyncFeatureProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(featureQueryExpressionStub, callBackRecorder.CallBack);

            Assert.NotNull(ar);
            Assert.False(ar.IsCompleted);

            Thread.Sleep(1000);

            Assert.Same(ar, callBackRecorder.Result);
            Assert.True(ar.IsCompleted);
            Assert.Same(_returnReaderStub, adapter.EndExecuteQuery(ar));

            mocks.VerifyAll();
        }
        public void MovingFundsUsingTransactions_AAA()
        {
            //Arrange
            MockRepository mocks = new MockRepository();
            IDatabaseManager databaseManager = mocks.StrictMock<IDatabaseManager>();
            IBankAccount accountOne = mocks.StrictMock<IBankAccount>(),
                         accountTwo = mocks.StrictMock<IBankAccount>();

            using (mocks.Ordered())
            {
                databaseManager.Expect(d => d.BeginTransaction()).Return(databaseManager);
                using (mocks.Unordered())
                {
                    accountOne.Expect(a => a.Withdraw(1000));
                    accountTwo.Expect(a => a.Deposit(1000));
                }
                databaseManager.Dispose();
            }

            //Act
            mocks.ReplayAll();

            Bank bank = new Bank(databaseManager);
            bank.TransferFunds(accountOne, accountTwo, 1000);

            //Assert
            databaseManager.VerifyAllExpectations();
            accountOne.VerifyAllExpectations();
            accountTwo.VerifyAllExpectations();
        }
Ejemplo n.º 21
0
        private void OrderedExpectationsForListeners(Action<MethodInvocation> afterHandleAction)
        {
            var mockRepository = new MockRepository();
            var mockA = mockRepository.StrictMock<IListenTo<ClockedEvent>.All>();
            var mockB = mockRepository.StrictMock<IListenTo<ClockedEvent>.All>();
            distributor.AddListener(mockA);
            distributor.AddListener(mockB);

            var clockedEvent1 = new ClockedEvent { ClockCycle = 1 };
            var clockedEvent2 = new ClockedEvent { ClockCycle = 2 };

            using (mockRepository.Ordered())
            {
                using (mockRepository.Unordered())
                {
                    Expect.Call(() => mockA.Handle(clockedEvent1)).WhenCalled(afterHandleAction);
                    Expect.Call(() => mockB.Handle(clockedEvent1)).WhenCalled(afterHandleAction);
                }
                using (mockRepository.Unordered())
                {
                    Expect.Call(() => mockA.Handle(clockedEvent2)).WhenCalled(afterHandleAction);
                    Expect.Call(() => mockB.Handle(clockedEvent2)).WhenCalled(afterHandleAction);
                }
            }

            mockRepository.ReplayAll();

            distributor.SendMessage(clockedEvent1);
            distributor.SendMessage(clockedEvent2);
            distributor.Distribute(1);
            distributor.Distribute(2);

            Thread.Sleep(550);
            mockRepository.VerifyAll();
        }