Exemple #1
0
        public void TestPrivateServiceProvider()
        {
            MockedGraphicsDeviceService originalService = new MockedGraphicsDeviceService();
            IServiceProvider            provider        = GraphicsDeviceServiceHelper.MakePrivateServiceProvider(
                originalService
                );

            IGraphicsDeviceService service = (IGraphicsDeviceService)provider.GetService(
                typeof(IGraphicsDeviceService)
                );

            Assert.AreSame(originalService, service);
        }
Exemple #2
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();
                }
            }
        }
Exemple #3
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();
                    }
                }
            }
        }