예제 #1
0
파일: Testing.cs 프로젝트: snorp/moon
		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;
		}
예제 #2
0
파일: Testing.cs 프로젝트: ynkbt/moon
        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);
        }