Example #1
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var projectDir = root / "GeneratedTestData" / "SystemTest1";
            var project    = projectDir / new FileName("SystemTest1.unoproj");
            var mainView   = projectDir / new FileName("MainView.ux");
            var dataDir    = projectDir / "build" / "Local" / "Designer" / "fs_data";
            var timeout    = TimeSpan.FromMinutes(3);

            Console.WriteLine("Setting up project");
            IOHelpers.DeleteAndCopyDirectory(root / "Projects" / "SystemTest1", projectDir);

            try
            {
                Console.WriteLine("Starting preview");
                fuseRunner.Preview(project, Optional.None());
                IOHelpers.WaitForFileToExist(dataDir / new FileName("output1"), timeout);
                Console.WriteLine("Replacing text");
                IOHelpers.ReplaceTextInFile(mainView, "output1", "output2");
                IOHelpers.WaitForFileToExist(dataDir / new FileName("output2"), timeout);
            }
            catch (Exception e)
            {
                throw new TestFailure(e.Message);
            }
            finally
            {
                ScreenCapture.Shoot("PreviewTestBeforeKill.png");
                fuseRunner.KillOrThrow();
            }
        }
Example #2
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var projectDir = root / "GeneratedTestData" / "AutomaticTestApp" / "App";
            var project    = projectDir / new FileName("App.unoproj");
            var timeout    = TimeSpan.FromMinutes(3);

            Console.WriteLine("Setting up project");
            IOHelpers.DeleteAndCopyDirectory(root / "Stuff" / "AutomatictestApp" / "App", projectDir);

            var testAppError = false;

            try
            {
                var wait = new ManualResetEvent(false);

                Console.WriteLine("Starting preview");
                fuseRunner.Preview(project, Optional.Some <Action <string> >(
                                       s =>
                {
                    if (s.Contains("TEST_APP_MSG:OK"))
                    {
                        wait.Set();
                    }
                    if (s.Contains("TEST_APP_MSG:ERROR"))
                    {
                        testAppError = true;
                        wait.Set();
                    }
                }));
                if (!wait.WaitOne(timeout))
                {
                    throw new TestFailure("Test timed out after " + timeout);
                }
                if (testAppError)
                {
                    throw new TestFailure("Test app failed");
                }
            }
            catch (Exception e)
            {
                throw new TestFailure(e.Message);
            }
            finally
            {
                ScreenCapture.Shoot("AutomaticTestApp-before-kill.png");
                fuseRunner.KillOrThrow();
            }
        }