public void TestNotSupportedExceptionForReferenceRasterizer() { MockedGraphicsDeviceService mock = new MockedGraphicsDeviceService( DeviceType.Reference ); mock.DeviceCreated += delegate(object sender, EventArgs arguments) { #if XNA_4 throw new InvalidOperationException("Simulated error for unit testing"); #else throw new NotSupportedException("Simulated error for unit testing"); #endif }; Console.Error.WriteLine( "The next line should contain an error message indicating that the reference " + "rasterizer could not be created" ); #if XNA_4 Assert.Throws <InvalidOperationException>( #else Assert.Throws <NotSupportedException>( #endif delegate() { mock.CreateDevice(); mock.DestroyDevice(); } ); }
public void TestRedundantDestroyInvocation() { MockedGraphicsDeviceService mock = new MockedGraphicsDeviceService(); using (IDisposable keeper = mock.CreateDevice()) { mock.DestroyDevice(); } // should not cause an exception }
public void TestRedundantDestroyInvocation() { MockedGraphicsDeviceService mock = new MockedGraphicsDeviceService(); using(IDisposable keeper = mock.CreateDevice()) { mock.DestroyDevice(); } // should not cause an exception }
public void TestDummyGraphicsDeviceServiceEvents() { MockedGraphicsDeviceService originalService = new MockedGraphicsDeviceService(); originalService.CreateDevice(); bool deviceExists = true; try { IGraphicsDeviceService dummyService; dummyService = GraphicsDeviceServiceHelper.MakeDummyGraphicsDeviceService( originalService.GraphicsDevice ); IGraphicsDeviceServiceSubscriber mockedSubscriber = mockSubscriber(dummyService); try { Expect.Once.On(mockedSubscriber).Method("DeviceResetting").WithAnyArguments(); Expect.Once.On(mockedSubscriber).Method("DeviceReset").WithAnyArguments(); originalService.ResetDevice(); this.mockery.VerifyAllExpectationsHaveBeenMet(); Expect.Once.On(mockedSubscriber).Method("DeviceDisposing").WithAnyArguments(); deviceExists = false; originalService.DestroyDevice(); this.mockery.VerifyAllExpectationsHaveBeenMet(); } finally { unmockSubscriber(dummyService, mockedSubscriber); } } finally { if(deviceExists) { originalService.DestroyDevice(); } } }
public void TestNotSupportedExceptionForReferenceRasterizer() { MockedGraphicsDeviceService mock = new MockedGraphicsDeviceService( DeviceType.Reference ); mock.DeviceCreated += delegate(object sender, EventArgs arguments) { throw new InvalidOperationException("Simulated error for unit testing"); }; Console.Error.WriteLine( "The next line should contain an error message indicating that the reference " + "rasterizer could not be created" ); Assert.Throws<InvalidOperationException>( delegate() { mock.CreateDevice(); mock.DestroyDevice(); } ); }