Harness for a test framework that allows asynchronous unit testing.
 /// <summary>
 /// Initialize the test harness.
 /// </summary>
 static App()
 {
     Harness = new TestHarness();
     Harness.Platform = TestPlatform.WindowsStore;
     Harness.LoadTestAssembly(typeof(FunctionalTestBase).GetTypeInfo().Assembly);
     Harness.LoadTestAssembly(typeof(LoginTests).GetTypeInfo().Assembly);
 }
 /// <summary>
 /// Initialize the test harness.
 /// </summary>
 static App()
 {
     Harness = new TestHarness();
     Harness.LoadTestAssembly(typeof(FunctionalTestBase).Assembly);
     Harness.LoadTestAssembly(typeof(LoginTests).Assembly);
     Harness.Platform = TestPlatform.WindowsPhone8;
 }
	    static AppDelegate()
	    {
            CurrentPlatform.Init();

	        Harness = new TestHarness();
            Harness.LoadTestAssembly(typeof(SQLiteStoreTests).Assembly);
	    }
        /// <summary>
        /// Initialize the test harness.
        /// </summary>
        static App()
        {
            ConsoleHelper.Attach();

            Harness = new TestHarness();
            Harness.LoadTestAssembly(typeof(MobileServiceSerializerTests).GetTypeInfo().Assembly);
        }
 /// <summary>
 /// Initialize the test harness.
 /// </summary>
 static App()
 {
     Harness = new TestHarness();
     Harness.LoadTestAssembly(typeof(FunctionalTestBase).Assembly);
     Harness.LoadTestAssembly(typeof(LoginTests).Assembly);
     Harness.Platform = string.Format("Win Phone 8.0|sdk v{0}|", TestPlatform.GetMobileServicesSdkVersion(typeof(App).Assembly));
 }
	    static AppDelegate()
	    {
            CurrentPlatform.Init();

	        Harness = new TestHarness();
            Harness.LoadTestAssembly (typeof (MobileServiceSerializerTests).GetTypeInfo().Assembly);
	    }
        public async void EndRun(TestHarness harness)
        {
            string completionFileName = "uwp_e2etest_completion.txt";
            StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
            string filePath = Path.Combine(storageFolder.Path, completionFileName);
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            StorageFile completionFile = await storageFolder.CreateFileAsync(completionFileName);
            File.WriteAllText(completionFile.Path, "Test Run Completed");

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                pnlFooter.Visibility = Visibility.Collapsed;
                if (harness.Failures > 0)
                {
                    lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0}/{1} tests failed!", harness.Failures, harness.Count);
                    lblResults.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E));
                }
                else
                {
                    lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0} tests passed!", harness.Count);
                }
                lblResults.Visibility = Visibility.Visible;
                if (!harness.Settings.ManualMode)
                    Application.Current.Exit();
            });
        }
 void ITestReporter.EndRun(TestHarness harness)
 {
     if (!harness.Settings.ManualMode)
     {
         File.WriteAllText(Path.Combine(Environment.ExternalStorageDirectory.AbsolutePath, "done_xamarin_e2e.txt"), "Completed successfully.");
     }
 }
 public void EndRun(TestHarness harness)
 {
     InvokeOnMainThread(() =>
     {
         UIAlertView alert = new UIAlertView("Tests Complete", "All done!", null, "Ok", null);
         alert.Show();
     });
 }
        void ITestReporter.Progress (TestHarness harness)
        {
            float value = harness.Progress;
            int count = harness.Count;
            if (count > 0)
                value = value / count;

            this.Progress = (int)(value * 10000);
        }
        static AppDelegate()
        {
            CurrentPlatform.Init();

            Harness = new TestHarness();
            Harness.Platform = string.Format("Xamarin.iOS|sdk v{0}|", TestPlatform.GetMobileServicesSdkVersion(typeof(AppDelegate).GetTypeInfo().Assembly));
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).GetTypeInfo().Assembly);
            Harness.LoadTestAssembly(typeof(PushFunctional).GetTypeInfo().Assembly);
        }
        static AppDelegate()
        {
            CurrentPlatform.Init();

            Harness = new TestHarness();
            Harness.Platform = TestPlatform.XamariniOS;
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).GetTypeInfo().Assembly);
            Harness.LoadTestAssembly(typeof(PushFunctional).GetTypeInfo().Assembly);
        }
        static App()
        {
            CurrentPlatform.Init();

            Harness = new TestHarness();
            Harness.Platform = string.Format("Xamarin.Android|sdk v{0}|", TestPlatform.GetMobileServicesSdkVersion(typeof(App).GetTypeInfo().Assembly));

            Harness.Reporter = Listener;
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).Assembly);
        }
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            Harness = new TestHarness();
            Harness.LoadTestAssembly(typeof(MobileServiceSerializerTests).GetTypeInfo().Assembly); //
            //Harness.LoadTestAssembly(typeof(LoginTests).GetTypeInfo().Assembly); //
        }
        static App()
        {
            CurrentPlatform.Init();

            Harness = new TestHarness();
            Harness.Platform = TestPlatform.XamarinAndroid;

            Harness.Reporter = Listener;
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).Assembly);
        }
 public void StartRun(TestHarness harness)
 {
     Dispatcher.BeginInvoke(() =>
     {
         lblCurrentTestNumber.Text = harness.Progress.ToString();
         lblTotalTestNumber.Text = harness.Count.ToString();
         lblFailureNumber.Tag = harness.Failures.ToString() ?? "0";
         progress.Value = 1;
     });
 }
        static App()
        {
            CurrentPlatform.Init();
            OfflineTests.StoreFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "test.db");
            Harness = new TestHarness();
            Harness.Platform = TestPlatform.XamarinAndroid;

            Harness.Reporter = Listener;
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).Assembly);
            Harness.LoadTestAssembly(typeof(PushFunctional).Assembly);
        }
 public async void StartRun(TestHarness harness)
 {
     await Dispatcher.InvokeAsync(() =>
     {
         lblCurrentTestNumber.Text = harness.Progress.ToString();
         lblTotalTestNumber.Text = harness.Count.ToString();
         lblFailureNumber.Tag = harness.Failures.ToString() ?? "0";
         progress.Value = 1;
         pnlFooter.Visibility = Visibility.Visible;
     });
 }
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            Harness = new TestHarness();
            Harness.Platform = TestPlatform.WindowsPhone81;
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).GetTypeInfo().Assembly);
            Harness.LoadTestAssembly(typeof(PushFunctional).GetTypeInfo().Assembly);
        }
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            Harness = new TestHarness();
            Harness.Platform = string.Format("Win Phone 8.1|sdk v{0}|", TestPlatform.GetMobileServicesSdkVersion(typeof(App).GetTypeInfo().Assembly));
            Harness.LoadTestAssembly(typeof(FunctionalTestBase).GetTypeInfo().Assembly);
            Harness.LoadTestAssembly(typeof(PushFunctional).GetTypeInfo().Assembly);
        }
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     Harness = new TestHarness
     {
         Platform = TestPlatform.UniversalWindowsPlatform
     };
     Harness.LoadTestAssembly(typeof(FunctionalTestBase).GetTypeInfo().Assembly);
     Harness.LoadTestAssembly(typeof(LoginTests).GetTypeInfo().Assembly);
 }
        public async void StartRun(TestHarness harness)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {

                lblCurrentTestNumber.Text = harness.Progress.ToString();
                lblTotalTestNumber.Text = harness.Count.ToString();
                lblFailureNumber.Tag = harness.Failures.ToString() ?? "0";
                progress.Value = 1;
                pnlFooter.Visibility = Visibility.Visible;
            });
        }
        public void Progress (TestHarness harness)
        {
	        InvokeOnMainThread (() => {
                this.numbers.Value = String.Format ("Passed: {0}  Failed: {1}", harness.Progress - harness.Failures, harness.Failures);
                ReloadData();

                float value = harness.Progress;
                int count = harness.Count;
                if (count > 0)
                    value = value / count;

                this.progress.Progress = value;
	        });
        }
 public async void Progress(TestHarness harness)
 {
     await Dispatcher.InvokeAsync(() =>
     {
         lblCurrentTestNumber.Text = harness.Progress.ToString();
         lblFailureNumber.Text = " " + (harness.Failures.ToString() ?? "0");
         double value = harness.Progress;
         int count = harness.Count;
         if (count > 0)
         {
             value = value * 100.0 / (double)count;
         }
         progress.Value = value;
     });
 }
 public async void Progress(TestHarness harness)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         lblCurrentTestNumber.Text = harness.Progress.ToString();
         lblFailureNumber.Text = " " + (harness.Failures.ToString() ?? "0");
         double value = harness.Progress;
         int count = harness.Count;
         if (count > 0)
         {
             value = value * 100.0 / (double)count;
         }
         progress.Value = value;
     });
 }
 public void EndRun(TestHarness harness)
 {
     Dispatcher.BeginInvoke(() =>
     {
         if (harness.Failures > 0)
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0}/{1} tests failed!", harness.Failures, harness.Count);
             lblResults.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E));
         }
         else
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0} tests passed!", harness.Count);
         }
         lblResults.Visibility = Visibility.Visible;
     });
 }
 public async void EndRun(TestHarness harness)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         pnlFooter.Visibility = Visibility.Collapsed;
         if (harness.Failures > 0)
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0}/{1} tests failed!", harness.Failures, harness.Count);
             lblResults.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E));
         }
         else
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0} tests passed!", harness.Count);
         }
         lblResults.Visibility = Visibility.Visible;
     });
 }
 public async void EndRun(TestHarness harness)
 {
     await Dispatcher.InvokeAsync(() =>
     {
         pnlFooter.Visibility = Visibility.Collapsed;
         if (harness.Failures > 0)
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0}/{1} tests failed!", harness.Failures, harness.Count);
             lblResults.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E));
         }
         else
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0} tests passed!", harness.Count);
         }
         lblResults.Visibility = Visibility.Visible;
         if (!harness.Settings.ManualMode)
             Environment.Exit(0);
     });
 }
Beispiel #29
0
        private static void LoadTestAssembly(TestHarness harness, Assembly testAssembly)
        {
            Dictionary <Type, TestGroup>   groups    = new Dictionary <Type, TestGroup>();
            Dictionary <TestGroup, object> instances = new Dictionary <TestGroup, object>();

            foreach (Type type in testAssembly.GetTypes())
            {
                foreach (MethodInfo method in type.GetMethods())
                {
                    if (method.GetCustomAttributes(true).Where(a => a.GetType() == typeof(TestMethodAttribute) ||
                                                               a.GetType() == typeof(AsyncTestMethodAttribute))
                        .Any())
                    {
                        TestGroup group    = null;
                        object    instance = null;
                        if (!groups.TryGetValue(type, out group))
                        {
                            group = CreateGroup(type);
                            harness.Groups.Add(group);
                            groups[type] = group;

                            instance = Activator.CreateInstance(type);
                            TestBase testBase = instance as TestBase;
                            if (testBase != null)
                            {
                                testBase.SetTestHarness(harness);
                            }

                            instances[group] = instance;
                        }
                        else
                        {
                            instances.TryGetValue(group, out instance);
                        }

                        TestMethod test = CreateMethod(type, instance, method);
                        group.Methods.Add(test);
                    }
                }
            }
        }
Beispiel #30
0
        /// <summary>
        /// Set the test harness configuration for manual or auto mode. Sets the app to  auto mode
        /// if more than 2 or more arguments are passed.
        /// </summary>
        /// <param name="harness">Test Harness object to be configured</param>
        /// <param name="queryString">Query string containing the parameters to be used</param>
        public static void SetAutoConfigQueryString(this TestHarness harness, String queryString)
        {
            harness.Settings.ManualMode = true;

            if (String.IsNullOrEmpty(queryString))
            {
                return;
            }

            var args = parseQueryString(queryString);

            if (args.Count > 0)
            {
                harness.Settings.Custom["MobileServiceRuntimeUrl"]               = getArgumentValue("url", args);
                harness.Settings.Custom["TestFrameworkStorageContainerUrl"]      = getArgumentValue("storageurl", args);
                harness.Settings.Custom["TestFrameworkStorageContainerSasToken"] = getArgumentValue("storagesastoken", args);
                harness.Settings.Custom["RuntimeVersion"] = getArgumentValue("runtimeversion", args);
                harness.Settings.TagExpression            = getArgumentValue("tags", args);
                harness.Settings.ManualMode = false;
            }
        }
 public async void EndRun(TestHarness harness)
 {
     await Dispatcher.InvokeAsync(() =>
     {
         pnlFooter.Visibility = Visibility.Collapsed;
         if (harness.Failures > 0)
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0}/{1} tests failed!", harness.Failures, harness.Count);
             lblResults.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E));
         }
         else
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0} tests passed!", harness.Count);
         }
         lblResults.Visibility = Visibility.Visible;
         if (App.Harness.Settings.Custom["Auto"] == "True")
         {
             Application.Current.Shutdown(harness.Failures);
         }
     });
 }
Beispiel #32
0
        public static void SetAutoConfig(this TestHarness harness, TestConfig config)
        {
            harness.Settings.ManualMode = true;

            if (config == null)
            {
                harness.Settings.ManualMode = false;
                return;
            }

            harness.Settings.Custom["MobileServiceRuntimeUrl"] = config.MobileServiceRuntimeUrl;
            harness.Settings.Custom["MobileServiceRuntimeKey"] = config.MobileServiceRuntimeKey;
            harness.Settings.Custom["MasterRunId"]             = config.MasterRunId;
            harness.Settings.Custom["RuntimeVersion"]          = config.RuntimeVersion;
            harness.Settings.Custom["CliendId"]        = config.CliendId;
            harness.Settings.Custom["ClientSecret"]    = config.ClientSecret;
            harness.Settings.Custom["DayLightUrl"]     = config.DayLightUrl;
            harness.Settings.Custom["DaylightProject"] = config.DaylightProject;
            harness.Settings.TagExpression             = config.TagExpression;
            harness.Settings.ManualMode = false;
        }
        private static void LoadTestAssembly(TestHarness harness, Assembly testAssembly)
        {
            var groups    = new Dictionary <Type, TestGroup>();
            var instances = new Dictionary <TestGroup, object>();

            foreach (Type type in testAssembly.ExportedTypes)
            {
                foreach (MethodInfo method in type.GetRuntimeMethods())
                {
                    if (method.GetCustomAttributes <TestMethodAttribute>().Any() ||
                        method.GetCustomAttributes <AsyncTestMethodAttribute>().Any())
                    {
                        object instance = null;
                        if (!groups.TryGetValue(type, out TestGroup group))
                        {
                            group = CreateGroup(type);
                            harness.Groups.Add(group);
                            groups[type] = group;

                            instance = Activator.CreateInstance(type);
                            if (instance is TestBase testBase)
                            {
                                testBase.SetTestHarness(harness);
                            }

                            instances[group] = instance;
                        }
                        else
                        {
                            instances.TryGetValue(group, out instance);
                        }

                        TestMethod test = CreateMethod(type, instance, method);
                        group.Methods.Add(test);
                    }
                }
            }
        }
 public void EndRun (TestHarness harness)
 {
 }
Beispiel #35
0
 internal void SetTestHarness(TestHarness testHarness)
 {
     this.TestHarness = testHarness;
 }