예제 #1
0
        public void AfterTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Log.Game.RemoveOutput(this.consoleLogOutput);
            Log.Core.RemoveOutput(this.consoleLogOutput);
            Log.Editor.RemoveOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }
            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            // Save local testing memory
            if (TestContext.CurrentContext.Result.Status == TestStatus.Passed && !System.Diagnostics.Debugger.IsAttached)
            {
                Formatter.WriteObject(TestHelper.LocalTestMemory, TestHelper.LocalTestMemoryFilePath, FormattingMethod.Xml);
            }

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
예제 #2
0
        public void BeforeTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment setup -----");

            // Set environment directory to Duality binary directory
            this.oldEnvDir = Environment.CurrentDirectory;
            string codeBaseURI  = typeof(DualityApp).Assembly.CodeBase;
            string codeBasePath = codeBaseURI.StartsWith("file:") ? codeBaseURI.Remove(0, "file:".Length) : codeBaseURI;

            codeBasePath = codeBasePath.TrimStart('/');
            Environment.CurrentDirectory = Path.GetDirectoryName(codeBasePath);

            // Add some Console logs manually for NUnit
            if (!Log.Game.Outputs.OfType <ConsoleLogOutput>().Any())
            {
                if (this.consoleLogOutput == null)
                {
                    this.consoleLogOutput = new ConsoleLogOutput();
                }
                Log.Game.AddOutput(this.consoleLogOutput);
                Log.Core.AddOutput(this.consoleLogOutput);
                Log.Editor.AddOutput(this.consoleLogOutput);
            }

            // Initialize Duality
            DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game);

            // Manually register pseudo-plugin for the Unit Testing Assembly
            this.unitTestPlugin = DualityApp.LoadPlugin(typeof(DualityTestsPlugin).Assembly, codeBasePath);

            // Create a dummy window, to get access to all the device contexts
            if (this.dummyWindow == null)
            {
                this.dummyWindow = new GameWindow(800, 600);
                this.dummyWindow.Context.LoadAll();
                this.dummyWindow.Visible = true;
                this.dummyWindow.Context.Update(this.dummyWindow.WindowInfo);
                this.dummyWindow.MakeCurrent();
                this.dummyWindow.ProcessEvents();
                DualityApp.TargetResolution = new Vector2(this.dummyWindow.Width, this.dummyWindow.Height);
                DualityApp.TargetMode       = this.dummyWindow.Context.GraphicsMode;
                DualityApp.InitGraphics();
            }

            // Load local testing memory
            TestHelper.LocalTestMemory = Formatter.TryReadObject <TestMemory>(TestHelper.LocalTestMemoryFilePath, FormattingMethod.Xml);

            Console.WriteLine("----- Duality environment setup complete -----");
        }
        public void AfterTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Log.Game.RemoveOutput(this.consoleLogOutput);
            Log.Core.RemoveOutput(this.consoleLogOutput);
            Log.Editor.RemoveOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }
            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
예제 #4
0
 /// <summary>
 /// On click of the button to clear the dashboard log output
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ClearDashboardLogOutput_Click(object sender, RoutedEventArgs e)
 {
     ConsoleLogOutput.Clear();
     Logging.LogConsole("Console log cleared");
 }
예제 #5
0
 /// <summary>
 /// When the Robot Log output text is changed. Event used to scrolling to see the last entry in the log
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ConsoleLogOutput_TextChanged(object sender, TextChangedEventArgs e)
 {
     ConsoleLogOutput.ScrollToEnd();
 }