Ejemplo n.º 1
0
        public void TestDummyGraphicsDeviceServiceEvents()
        {
            MockedGraphicsDeviceService originalService = new MockedGraphicsDeviceService();

            originalService.CreateDevice();

            bool deviceExists = true;

            try {
                IGraphicsDeviceService dummyService;
                dummyService = GraphicsDeviceServiceHelper.MakeDummyGraphicsDeviceService(
                    originalService.GraphicsDevice
                    );
                Mock <IGraphicsDeviceServiceSubscriber> mockedSubscriber = mockSubscriber(dummyService);
                try {
                    mockedSubscriber.Expects.One.Method(
                        m => m.DeviceResetting(null, null)
                        ).WithAnyArguments();
                    mockedSubscriber.Expects.One.Method(
                        m => m.DeviceReset(null, null)
                        ).WithAnyArguments();

                    originalService.ResetDevice();
                    this.mockery.VerifyAllExpectationsHaveBeenMet();

                    mockedSubscriber.Expects.One.Method(
                        m => m.DeviceDisposing(null, null)
                        ).WithAnyArguments();

                    deviceExists = false;
                    originalService.DestroyDevice();

                    this.mockery.VerifyAllExpectationsHaveBeenMet();
                }
                finally {
                    unmockSubscriber(dummyService, mockedSubscriber);
                }
            }
            finally {
                if (deviceExists)
                {
                    originalService.DestroyDevice();
                }
            }
        }
Ejemplo n.º 2
0
        public void TestDummyGraphicsDeviceService()
        {
            MockedGraphicsDeviceService originalService = new MockedGraphicsDeviceService();

            using (IDisposable keeper = originalService.CreateDevice()) {
                IGraphicsDeviceService dummyService;
                dummyService = GraphicsDeviceServiceHelper.MakeDummyGraphicsDeviceService(
                    originalService.GraphicsDevice
                    );
                try {
                    Assert.AreSame(originalService.GraphicsDevice, dummyService.GraphicsDevice);
                }
                finally {
                    IDisposable disposable = dummyService as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
        }