Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            System.Console.WriteLine("Loading test suite...");

            // Load static container of all tests.
            List <TestEnvironment> listEnvironments = new List <TestEnvironment>();

            TestEnvironments.AddAll(listEnvironments);

            int testIndex = 1;

            foreach (TestEnvironment environment in listEnvironments)
            {
                string message = string.Format("{5} - Running test {3} / {4} - {0} on {1} (Snapshot: {2})",
                                               environment.Description,
                                               environment.OperatingSystem,
                                               environment.SnapshotName,
                                               testIndex,
                                               listEnvironments.Count,
                                               DateTime.Now);

                System.Console.WriteLine(message);

                TestRunner runner = new TestRunner(true, environment, true);
                runner.TestCompleted += new TestRunner.TestCompletedDelegate(runner_TestCompleted);
                if (!runner.Run())
                {
                    return(-1);
                }

                testIndex++;
            }

            return(0);
        }
Ejemplo n.º 2
0
        private void formConfigurations_Load(object sender, EventArgs e)
        {
            if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
            {
                MessageBox.Show("Only one instance of this application can be started.", "VMwareIntegration", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }

            try
            {
                List <TestEnvironment> listEnvironments = new List <TestEnvironment>();
                TestEnvironments.AddAll(listEnvironments);


                foreach (TestEnvironment environment in listEnvironments)
                {
                    ListViewItem item = listConfigurations.Items.Add(environment.Description);
                    item.SubItems.Add(environment.OperatingSystem);
                    item.SubItems.Add(environment.DatabaseType);
                    item.SubItems.Add(environment.SnapshotName);
                    item.SubItems.Add(""); // Status
                    item.Tag     = environment;
                    item.Checked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, "VMwareIntegration", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }
        }
        public void UniquePointsFromIntersection_should_throw_exception_when_read_if_unresolved()
        {
            var rel = TestEnvironments.CenteredVertical_CenteredHorizontal();

            Action act = () => { var x = rel.PropertiesA.UniquePointsFromIntersection; };

            act.Should().Throw <UnresolvedPropertyException>("because the property was read before it was actually resolved");
        }
        public void Given_CenteredVertical_to_CenteredHorizontal_should_return_true_for_GeometryB()
        {
            TestEnvironments.CenteredVertical_CenteredHorizontal()
            .Resolve()
            .IfIntersectionExists()
            .Results(out var resA, out var resB);

            resB.IntersectionExists.Should().BeTrue("because the curves do intersect");
        }
Ejemplo n.º 5
0
        public void Given_CenteredVertical_to_CenteredHorizontal_when_reviewing_GeometryB_should_find_one_unique_point()
        {
            TestEnvironments.CenteredVertical_CenteredHorizontal()
            .Resolve()
            .PointsFromIntersection()
            .Results(out var resA, out var resB);

            var val = resB.UniquePointsFromIntersection.Count;

            val.Should().Be(1, "because the curves only intersect once");
        }
Ejemplo n.º 6
0
        public void Given_ShuffledPinwheel_should_return_four_groups()
        {
            TestEnvironments.ShuffledPinwheel()
            .Resolve()
            .GroupsByColinearity()
            .Results(out var res);

            var val = res.GroupsByColinearity.Count;

            val.Should().Be(4, "because the pinwheel has eight spokes");
        }
Ejemplo n.º 7
0
        public void Given_ParallelOffsetCurvesOneDashed_returns_accurate_groups()
        {
            TestEnvironments.ParallelOffsetCurvesOneDashed()
            .Resolve()
            .GroupsByColinearity()
            .Results(out var res);

            var val = res.GroupsByColinearityIndexMap[0] == res.GroupsByColinearityIndexMap[1];

            val.Should().BeTrue("because the first two segments are colinear");
        }
Ejemplo n.º 8
0
        public void Given_ParallelOffsetCurvesOneDashed_returns_two_groups()
        {
            TestEnvironments.ParallelOffsetCurvesOneDashed()
            .Resolve()
            .GroupsByColinearity()
            .Results(out var res);

            var val = res.GroupsByColinearity.Count;

            val.Should().Be(2, "because there are two colinear groups of curves");
        }
Ejemplo n.º 9
0
        public void Given_HorizontalDashedLine_should_return_one_group()
        {
            TestEnvironments.HorizontalDashedLine()
            .Resolve()
            .GroupsByColinearity()
            .Results(out var res);

            var val = res.GroupsByColinearity.Count;

            val.Should().Be(1, "because all dashes are colinear");
        }
Ejemplo n.º 10
0
        public void Given_ParallelOffsetCurves_should_return_two_groups()
        {
            TestEnvironments.ParallelOffsetCurves()
            .Resolve()
            .GroupsByColinearity()
            .Results(out var res);

            var val = res.GroupsByColinearity.Count;

            val.Should().Be(2, "because there are two independent curves");
        }
        public void Given_CenteredVertical_to_CenteredHorizontal_with_options_should_return_true_for_GeometryB()
        {
            var rel  = TestEnvironments.CenteredVertical_CenteredHorizontal();
            var opts = new CurveToCurveReviewOptions()
            {
                DoIfIntersectionExists = true
            };

            rel.Review(opts, out var resA, out var resB);

            resB.IntersectionExists.Should().BeTrue("because the curves do intersect");
        }
Ejemplo n.º 12
0
        static int Main(string[] args)
        {
            var softwareUnderTest = args[0];

            _logFile = string.Format("{0}-{1}.log", softwareUnderTest, DateTime.Now.ToString("yyyy-MM-dd HHmmss"));

            if (!File.Exists(softwareUnderTest))
            {
                LogText(string.Format("The file {0} does not exist.", softwareUnderTest));
                return(-1);
            }

            LogText("Loading test suite...");

            // Load static container of all tests.
            List <TestEnvironment> listEnvironments = new List <TestEnvironment>();

            TestEnvironments.AddAll(listEnvironments);

            int testIndex = 0;

            var f = TaskScheduler.Default;

            var options = new ParallelOptions()
            {
                MaxDegreeOfParallelism = 4,
            };

            // We can run tests on XP and Vista/2003/2008 at the same time since it's separate VMware images.
            var environmentsGroupedByVmwareImage = listEnvironments.GroupBy(item => item.VMwarePath).ToList();

            var partitioner = Partitioner.Create(environmentsGroupedByVmwareImage, EnumerablePartitionerOptions.NoBuffering);

            Parallel.ForEach(partitioner, options, environmentGroup =>
            {
                foreach (var environment in environmentGroup)
                {
                    int localIndex;

                    lock (_lockCounterTest)
                    {
                        localIndex = ++testIndex;

                        string message =
                            string.Format("{0}: {1}/{2} - Test: {3} on {4} with db {5}. Image: {6} (Snapshot: {7})",
                                          DateTime.Now,
                                          localIndex,
                                          listEnvironments.Count,
                                          environment.Description,
                                          environment.OperatingSystem,
                                          environment.DatabaseType,
                                          Path.GetFileName(environment.VMwarePath),
                                          environment.SnapshotName);

                        LogText(message);
                    }

                    var runner = new TestRunner(true, environment, false, softwareUnderTest);

                    try
                    {
                        runner.Run();
                        LogText(string.Format("{0}: Test {1} completed successfully.", DateTime.Now, localIndex));
                    }
                    catch (Exception ex)
                    {
                        LogText(string.Format("{0}: Test {1} failed.", DateTime.Now, localIndex));
                        LogText(ex.ToString());

                        throw;
                    }
                }
            });

            System.Console.WriteLine("All tests completed succesfully.");
            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Console.WriteLine("Press Enter to exit.");
                System.Console.ReadLine();
            }

            return(0);
        }
Ejemplo n.º 13
0
        static int Main(string[] args)
        {
            var softwareUnderTest = args[0];

            _logFile = args[1];
            _logFile = _logFile.Replace("%TIMESTAMP%", DateTime.Now.ToString("yyyy-MM-dd HHmmss"));

            if (!File.Exists(softwareUnderTest))
            {
                LogText(string.Format("The file {0} does not exist.", softwareUnderTest));
                return(-1);
            }

            if (softwareUnderTest.Equals(_logFile, StringComparison.InvariantCultureIgnoreCase))
            {
                LogText("Software under test cannot be same as log file.");
                return(-1);
            }

            LogText("Loading test suite...");

            // Load static container of all tests.
            List <TestEnvironment> listEnvironments = new List <TestEnvironment>();

            TestEnvironments.AddAll(listEnvironments);

            int testIndex   = 0;
            int failedTests = 0;

            var options = new ParallelOptions()
            {
                MaxDegreeOfParallelism = 8,
            };

            // We can run tests on XP and Vista/2003/2008 at the same time since it's separate VMware images.
            var environmentsGroupedByVmwareImage = listEnvironments.GroupBy(item => item.VMwarePath).ToList();

            var partitioner = Partitioner.Create(environmentsGroupedByVmwareImage, EnumerablePartitionerOptions.NoBuffering);

            Parallel.ForEach(partitioner, options, environmentGroup =>
            {
                foreach (var environment in environmentGroup)
                {
                    int localIndex;

                    lock (_lockCounterTest)
                    {
                        localIndex = ++testIndex;

                        string message =
                            string.Format("{0}: {1}/{2} - Test: {3} on {4} with db {5}. Image: {6} (Snapshot: {7})",
                                          DateTime.Now,
                                          localIndex,
                                          listEnvironments.Count,
                                          environment.Description,
                                          environment.OperatingSystem,
                                          environment.DatabaseType,
                                          Path.GetFileName(environment.VMwarePath),
                                          environment.SnapshotName);

                        LogText(message);
                    }

                    var runner = new TestRunner(true, environment, false, softwareUnderTest);

                    try
                    {
                        runner.Run();

                        LogText(string.Format("{0}: Test {1} completed successfully.", DateTime.Now, localIndex));
                    }
                    catch (Exception ex)
                    {
                        LogText(string.Format("{0}: Test {1} failed.", DateTime.Now, localIndex));
                        LogText(ex.ToString());

                        lock (_lockCounterTest)
                        {
                            failedTests++;
                        }
                    }
                }
            });

            if (failedTests == 0)
            {
                System.Console.WriteLine("All tests suites completed succesfully. Press Enter to exit.");
            }
            else
            {
                System.Console.WriteLine(string.Format("{0} tests suites failed. Press Enter to exit.", failedTests));
            }

            System.Console.ReadLine();
            return(0);
        }