public static UIElement CreateTestPage (Application app) { settings = new UnitTestSettings (); app.UnhandledException += Application_UnhandledException; moonlog = new MoonLogProvider (); harness = new Microsoft.Silverlight.Testing.UnitTesting.Harness.UnitTestHarness (); settings.TestHarness = harness; settings.TestAssemblies.Add (app.GetType ().Assembly); UnitTestSystem.PrepareCustomLogProviders (settings); settings.LogProviders.Add (moonlog); settings.RuntimeVersion = Int32.Parse (Deployment.Current.RuntimeVersion.Split('.')[0]); // Silverlight thinks HtmlPage.Document.DocumentUri.Query is empty // so lets just manually parse instead. This allows tagging to work on SL. if (HtmlPage.Document.DocumentUri.OriginalString.IndexOf ('?') > 0) { settings.TagExpression = HtmlPage.Document.DocumentUri.OriginalString.Substring (HtmlPage.Document.DocumentUri.OriginalString.IndexOf ('?') + 1); if (settings.TagExpression.IndexOf ('#') > 0) settings.TagExpression = settings.TagExpression.Remove (settings.TagExpression.IndexOf ('#')); } test_page = UnitTestSystem.CreateTestPage (settings); settings.TestHarness.TestHarnessCompleted += new EventHandler<TestHarnessCompletedEventArgs> (Harness_Completed); return test_page; }
public static UIElement CreateTestPage(Application app) { settings = new UnitTestSettings(); app.UnhandledException += Application_UnhandledException; moonlog = new MoonLogProvider(); harness = new Microsoft.Silverlight.Testing.UnitTesting.Harness.UnitTestHarness(); settings.TestHarness = harness; settings.TestAssemblies.Add(app.GetType().Assembly); UnitTestSystem.PrepareCustomLogProviders(settings); settings.LogProviders.Add(moonlog); settings.RuntimeVersion = Int32.Parse(Deployment.Current.RuntimeVersion.Split('.')[0]); // Silverlight thinks HtmlPage.Document.DocumentUri.Query is empty // so lets just manually parse instead. This allows tagging to work on SL. if (HtmlPage.Document.DocumentUri.OriginalString.IndexOf('?') > 0) { settings.TagExpression = HtmlPage.Document.DocumentUri.OriginalString.Substring(HtmlPage.Document.DocumentUri.OriginalString.IndexOf('?') + 1); if (settings.TagExpression.IndexOf('#') > 0) { settings.TagExpression = settings.TagExpression.Remove(settings.TagExpression.IndexOf('#')); } List <string> exps = new List <string> (settings.TagExpression.Split('&')); for (int i = exps.Count - 1; i >= 0; i--) { if (exps [i].StartsWith("version=") || exps [i].StartsWith("bot_mode=")) { exps.RemoveAt(i); } } settings.TagExpression = string.Join("&", exps.ToArray()); } test_page = UnitTestSystem.CreateTestPage(settings); settings.TestHarness.TestHarnessCompleted += new EventHandler <TestHarnessCompletedEventArgs> (Harness_Completed); return(test_page); }