Пример #1
0
        static void Run(XSpec root)
        {
            var            stack = new List <XSpec>();
            List <XSpec[]> tests = root.GatherTests(stack).ToList();

            for (int i = 0; i < tests.Count; i++)
            {
                XSpec[] test = tests[i];
                for (int j = 0; j < test.Length; j++)
                {
                    if (!test[j].Exec())
                    {
                        break;
                    }
                }
            }

            var  builder = new StringBuilder();
            bool passed  = root.Report(builder, 0);

            if (!passed)
            {
                throw new AssertFailedException("\r\n" + builder.ToString());
            }
        }
Пример #2
0
        static void RunQuick(XSpec root)
        {
            XSpec[] tests = root.GatherTestsQuick().ToArray();
            int     end   = 0;

            while (end < tests.Length)
            {
                // First, fast-forward, resetting state until we get up to just past our last failure.
                bool failedPrereqs = false;
                for (int i = 0; i < end; i++)
                {
                    if (tests[i].type > NodeType.When)
                    {
                        continue;
                    }
                    if (!tests[i].Exec())
                    {
                        failedPrereqs = true;
                        break;
                    }
                }

                if (failedPrereqs)
                {
                    break;
                }
                for ( ; end < tests.Length; end++)
                {
                    if (!tests[end].Exec())
                    {
                        break;
                    }
                }
                end++; // Skip forward, so we can make progress.
            }

            var  builder = new StringBuilder();
            bool passed  = root.Report(builder, 0);

            if (!passed)
            {
                throw new AssertFailedException("\r\n" + builder.ToString());
            }
        }