public void TestRenderSkybox() { MockedGraphicsDeviceService mockGraphicsDeviceService = new MockedGraphicsDeviceService(DeviceType.Reference); using (IDisposable keeper = mockGraphicsDeviceService.CreateDevice()) { using ( BasicEffect effect = new BasicEffect(mockGraphicsDeviceService.GraphicsDevice) ) { using ( SkyboxCube skyboxCube = new SkyboxCube( mockGraphicsDeviceService.GraphicsDevice ) ) { skyboxCube.AssignVertexBuffer(); EffectTechnique technique = effect.CurrentTechnique; for (int pass = 0; pass < technique.Passes.Count; ++pass) { technique.Passes[pass].Apply(); skyboxCube.DrawNorthernFace(); skyboxCube.DrawEasternFace(); skyboxCube.DrawSouthernFace(); skyboxCube.DrawWesternFace(); skyboxCube.DrawUpperFace(); skyboxCube.DrawLowerFace(); } } } } }
public void TestBeginEnd() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { #if XNA_4 using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); for (int pass = 0; pass < test.Passes; ++pass) { test.Apply(pass); } } #else using (EffectPool pool = new EffectPool()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice, pool)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); test.Begin(); try { for (int pass = 0; pass < test.Passes; ++pass) { test.BeginPass(pass); test.EndPass(); } } finally { test.End(); } } } #endif } }
public void TestEqualsWithDifferentObject() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { #if XNA_4 using (BasicEffect effect1 = new BasicEffect(service.GraphicsDevice)) { using (BasicEffect effect2 = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test1 = new TestEffectDrawContext(effect1); TestEffectDrawContext test2 = new TestEffectDrawContext(effect2); Assert.IsFalse(test1.Equals((object)test2)); } } #else using (EffectPool pool = new EffectPool()) { using (BasicEffect effect1 = new BasicEffect(service.GraphicsDevice, pool)) { using (BasicEffect effect2 = new BasicEffect(service.GraphicsDevice, pool)) { TestEffectDrawContext test1 = new TestEffectDrawContext(effect1); TestEffectDrawContext test2 = new TestEffectDrawContext(effect2); Assert.IsFalse(test1.Equals((object)test2)); } } } #endif } }
public void TestSelect() { MockedGraphicsDeviceService mockGraphicsDeviceService = new MockedGraphicsDeviceService(); using (IDisposable keeper = mockGraphicsDeviceService.CreateDevice()) { using ( TestStaticMesh test = new TestStaticMesh( mockGraphicsDeviceService.GraphicsDevice, 4 ) ) { test.Select(); #if XNA_4 Assert.AreSame( test.VertexBuffer, mockGraphicsDeviceService.GraphicsDevice.GetVertexBuffers()[0].VertexBuffer ); #else Assert.AreSame( test.VertexBuffer, mockGraphicsDeviceService.GraphicsDevice.Vertices[0].VertexBuffer ); #endif } } }
public void TestContentAccess() { using (XnaGame game = new XnaGame()) { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (service.CreateDevice()) { game.Services.AddService(typeof(IGraphicsDeviceService), service); string assetPath = writeBytesToTempFile( Resources.UnitTestResources.UnitTestEffect ); try { game.Content.RootDirectory = Path.GetDirectoryName(assetPath); string assetName = Path.GetFileNameWithoutExtension(assetPath); SharedGameContentManager adapter = new SharedGameContentManager(game); Effect loadedFromGame = game.Content.Load <Effect>(assetName); Effect loadedFromShared = adapter.Load <Effect>(assetName); Assert.AreSame(loadedFromGame, loadedFromShared); } finally { File.Delete(assetPath); } } // using graphics device } // using game }
public void TestConstructor() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (Drawable drawable = new TestDrawable(service)) { Assert.IsNotNull(drawable); } }
public void TestDraw() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (Drawable drawable = new TestDrawable(service)) { drawable.Draw(new GameTime()); } }
public void TestInitialization() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( SharedContentManager contentManager = new SharedContentManager(gameServices) ) { contentManager.Initialize(); } }
public void TestConstructor() { MockedGraphicsDeviceService mockGraphicsDeviceService = new MockedGraphicsDeviceService(); using (IDisposable keeper = mockGraphicsDeviceService.CreateDevice()) { SkyboxCube theSkybox = new SkyboxCube(mockGraphicsDeviceService.GraphicsDevice); theSkybox.Dispose(); } }
public void TestConstructor() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (IDisposable context = new BasicEffectDrawContext(service.GraphicsDevice)) { Assert.IsNotNull(context); } } }
public void TestCreateGraphicsDeviceBeforeConstructor() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (Drawable drawable = new TestDrawable(service)) { Assert.AreSame(drawable.GraphicsDevice, service.GraphicsDevice); } } }
public void TestConstructor() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); Assert.GreaterOrEqual(test.Passes, 1); } } }
public void TestEqualsWithSameObject() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); Assert.IsTrue(test.Equals((object)test)); } } }
public void TestConstructor() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( SharedContentManager contentManager = new SharedContentManager(gameServices) ) { // Nonsense, but avoids compiler warning about unused variable :) Assert.IsNotNull(contentManager); } }
public void TestEffectRetrieval() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); Assert.AreSame(effect, test.Effect); } } }
public void TestEqualsWithIncpmpatibleDrawContext() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test1 = new TestEffectDrawContext(effect); TestDrawContext test2 = new TestDrawContext(); Assert.IsFalse(test1.Equals((object)test2)); } } }
public void Setup() { this.mockedGraphicsDeviceService = new MockedGraphicsDeviceService(DeviceType.Reference); this.mockedGraphicsDeviceService.CreateDevice(); MockedGraphicsDeviceService mockedService = this.mockedGraphicsDeviceService; this.contentManager = new ResourceContentManager( GraphicsDeviceServiceHelper.MakePrivateServiceProvider(mockedService), Resources.UnitTestResources.ResourceManager ); }
public void TestServiceRegistration() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( SharedContentManager contentManager = new SharedContentManager(gameServices) ) { object service = gameServices.GetService(typeof(ISharedContentService)); Assert.AreSame(contentManager, service); } }
public void TestInitializationWithExistingGraphicsDevice() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using(IDisposable keeper = mockedGraphics.CreateDevice()) { using( SharedContentManager contentManager = new SharedContentManager(gameServices) ) { contentManager.Initialize(); } } }
public void TestThrowOnLoadAssetBeforeInitialization() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( TestSharedContentManager contentManager = new TestSharedContentManager(gameServices) ) { Assert.Throws<InvalidOperationException>( delegate() { contentManager.Load<BadImageFormatException>("I'm a funny asset"); } ); } }
public void TestSimpleConstructor() { MockedGraphicsDeviceService mockGraphicsDeviceService = new MockedGraphicsDeviceService(); using (IDisposable keeper = mockGraphicsDeviceService.CreateDevice()) { WaterGrid theGrid = new WaterGrid( mockGraphicsDeviceService.GraphicsDevice, new Vector2(-10.0f, -10.0f), new Vector2(10.0f, 10.0f) ); theGrid.Dispose(); } }
public void TestSimpleConstructor() { MockedGraphicsDeviceService mockGraphicsDeviceService = new MockedGraphicsDeviceService(); using (IDisposable keeper = mockGraphicsDeviceService.CreateDevice()) { using ( TestIndexedStaticMesh test = new TestIndexedStaticMesh( mockGraphicsDeviceService.GraphicsDevice, 4, 4 ) ) { } } }
public void TestPrivateServiceProvider() { MockedGraphicsDeviceService originalService = new MockedGraphicsDeviceService(); IServiceProvider provider = GraphicsDeviceServiceHelper.MakePrivateServiceProvider( originalService ); IGraphicsDeviceService service = (IGraphicsDeviceService)provider.GetService( typeof(IGraphicsDeviceService) ); Assert.AreSame(originalService, service); }
public void TestCreateFromServiceProvider() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); GameServiceContainer container = new GameServiceContainer(); container.AddService(typeof(IGraphicsDeviceService), service); using (IDisposable keeper = service.CreateDevice()) { using (Drawable drawable = new TestDrawable(container)) { Assert.AreSame(drawable.GraphicsDevice, service.GraphicsDevice); } } }
public void TestLoadAsset() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( TestSharedContentManager contentManager = new TestSharedContentManager(gameServices) ) { contentManager.Initialize(); Assert.IsNull(contentManager.LastLoadedAsset); contentManager.Load<BadImageFormatException>("I'm a funny asset"); Assert.AreEqual("I'm a funny asset", contentManager.LastLoadedAsset); } }
public void TestBeginEnd() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); for (int pass = 0; pass < test.Passes; ++pass) { test.Apply(pass); } } } }
public void TestThrowOnInvalidSegmentCountX() { MockedGraphicsDeviceService mockGraphicsDeviceService = new MockedGraphicsDeviceService(); using (IDisposable keeper = mockGraphicsDeviceService.CreateDevice()) { Assert.Throws <ArgumentException>( delegate() { new WaterGrid( mockGraphicsDeviceService.GraphicsDevice, Vector2.Zero, Vector2.Zero, 0, 20 ); } ); } }
public void TestGraphicsDeviceReset() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using (TestDrawable drawable = new TestDrawable(service)) { Assert.AreEqual(0, drawable.LoadContentFalseCount); Assert.AreEqual(0, drawable.UnloadContentFalseCount); service.ResetDevice(); Assert.AreEqual(1, drawable.LoadContentFalseCount); Assert.AreEqual(1, drawable.UnloadContentFalseCount); } } }
public void TestVectorFontReading() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using ( ResourceContentManager contentManager = new ResourceContentManager( GraphicsDeviceServiceHelper.MakePrivateServiceProvider(service), Resources.UnitTestResources.ResourceManager ) ) { VectorFont font = contentManager.Load <VectorFont>("UnitTestVectorFont"); Assert.IsNotNull(font); } } }
public void TestDispose() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( SharedContentManager contentManager = new SharedContentManager(gameServices) ) { object service = gameServices.GetService(typeof(ISharedContentService)); Assert.AreSame(contentManager, service); } // Make sure the service was unregistered again when the shared content manager // got disposed object serviceAfterDispose = gameServices.GetService(typeof(ISharedContentService)); Assert.IsNull(serviceAfterDispose); }