// Only used in debug mode #if DEBUG #region Using directives using System; using System.Collections.Generic; using System.Text; using XnaTetris.Helpers; using Microsoft.Xna.Framework; #endregion namespace XnaTetris.Game { /// /// Test game /// public class TestGame : TetrisGame//BaseGame { #region Variables /// /// Render delegate for rendering methods, also used for many other /// methods. /// public delegate void RenderDelegate(); /// /// Init code /// protected RenderDelegate renderCode; #endregion #region Constructor /// /// Create test game /// /// Set windows title /// Window width /// Window height /// Set init code /// Set update code /// Set render code protected TestGame(string setWindowsTitle, RenderDelegate setRenderCode) { this.Window.Title = setWindowsTitle; #if !XBOX360 #if DEBUG // Force window on top WindowsHelper.ForceForegroundWindow(this.Window.Handle.ToInt32()); #endif #endif renderCode = setRenderCode; } // TestGame(setWindowsTitle, setRenderCode) #endregion #region Update /// /// Update /// protected override void Update(GameTime time) { base.Update(time); } // Update() #endregion #region Draw /// /// Draw /// protected override void Draw(GameTime gameTime) { // Drawing code if (renderCode != null) renderCode(); base.Draw(gameTime); } // Draw(gameTime) #endregion #region Start test public static TestGame game; /// /// Start /// /// Test name /// Render code public static void Start(string testName, RenderDelegate renderCode) { using (game = new TestGame(testName, renderCode)) { game.Run(); } // using (game) } // Start(testName, initCode, updateCode) /// /// Start /// /// Render code public static void Start(RenderDelegate renderCode) { using (game = new TestGame("Unit Test", renderCode)) { game.Run(); } // using (game) } // Start(testName, initCode, updateCode) #endregion #region Unit Testing #if DEBUG #region TestEmptyGame /// /// Test empty game /// public static void TestEmptyGame() { TestGame.Start(null); } // TestEmptyGame() #endregion #endif #endregion } // class TestGame } // namespace XnaTetris.Game #endif