Exemplo n.º 1
0
    // Run a series of tests with different table and collection styles.
    bool RunTest()
    {
        // Number of nodes we'll allocate in each run (we could take this as an argument instead).
        int numNodes = 10000;

        // Run everything under an exception handler since test errors are reported as exceptions.
        try
        {
            // Run a pass with each table style. For each style run through the collection styles in the order
            // None, Alternate, Random and All. This sequence is carefully selected to remove progressively
            // more nodes from the array (since, within a given TestSet instance, once a node has actually
            // been collected it won't be resurrected for future runs).

            TestSet ts1 = new TestSet(TableStyle.Unconnected, numNodes);
            ts1.Run(CollectStyle.None);
            ts1.Run(CollectStyle.Alternate);
            ts1.Run(CollectStyle.Random);
            ts1.Run(CollectStyle.All);

            TestSet ts2 = new TestSet(TableStyle.ForwardLinked, numNodes);
            ts2.Run(CollectStyle.None);
            ts2.Run(CollectStyle.Alternate);
            ts2.Run(CollectStyle.Random);
            ts2.Run(CollectStyle.All);

            TestSet ts3 = new TestSet(TableStyle.BackwardLinked, numNodes);
            ts3.Run(CollectStyle.None);
            ts3.Run(CollectStyle.Alternate);
            ts3.Run(CollectStyle.Random);
            ts3.Run(CollectStyle.All);

            TestSet ts4 = new TestSet(TableStyle.Random, numNodes);
            ts4.Run(CollectStyle.None);
            ts4.Run(CollectStyle.Alternate);
            ts4.Run(CollectStyle.Random);
            ts4.Run(CollectStyle.All);
        }
        catch (TestException te)
        {
            // "Expected" errors.
            Console.WriteLine("TestError: {0}", te.Message);
            return(false);
        }
        catch (Exception e)
        {
            // Totally unexpected errors (probably shouldn't see these unless there's a test bug).
            Console.WriteLine("Unexpected exception: {0}", e.GetType().Name);
            return(false);
        }

        // If we get as far as here the test succeeded.
        return(true);
    }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Boolean TestMode = true;

            if (TestMode)
            {
                TestSet.Run();
            }
            else
            {
                // --deletedomain "My Domain Name"
                Parser.Default.ParseArguments <Options>(args)
                .WithParsed <Options>(o =>
                {
                    if (o.Verbose)
                    {
                        Console.WriteLine($"Verbose output enabled. Current Arguments: -v {o.Verbose}");
                        Console.WriteLine("Quick Start Example! App is in Verbose mode!");
                    }
                    else
                    {
                        Console.WriteLine($"Current Arguments: -v {o.Verbose}");
                        Console.WriteLine("Quick Start Example!");
                    }
                });
                Console.ReadKey();
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            GlobalConfig conf = new GlobalConfig();

            conf.readConfig();

            Session session = new Session(conf);

            IList <IDictionary <string, string> > cases = session.getCases();

            if (cases.Count == 0)
            {
                throw new Exception("No tests found.");
            }

            TestSet ts = new TestSet(session, cases);

            ts.Run();

            /*
             * XmlDocument doc = new XmlDocument();
             * doc.Load("tests.xml");
             *
             * try
             * {
             *  IContext ctx = new Context();
             *  ctx.updateFrom(GlobalConfig.getProperties());
             *
             *  ConnectionFactory.Init();
             *
             *  ITestSet testSet = new TestSet(doc, ctx);
             *
             *
             *  testSet.testStart += testSet_testStart;
             *  testSet.testError += testSet_testError;
             *  testSet.testFinish += testSet_testFinish;
             *
             *  testSet.blockStart +=  testSet_blockStart;
             *  testSet.blockError += testSet_blockError;
             *  testSet.blockFinish += testSet_blockFinish;
             *
             *  testSet.elementStart += testSet_elementStart;
             *  testSet.elementFinish += testSet_elementFinish;
             *  testSet.elementError += testSet_elementError;
             *
             *
             *  bool r = testSet.Run();
             *  Console.WriteLine("Test count: {0}, Run:{1}", testSet.Count, r);
             * }
             * catch (Exception e)
             * {
             *  Console.WriteLine("TestSet Error: {0}", e);
             * }
             *
             */
            Console.WriteLine("Press any key to close this window");
            Console.ReadKey();
        }
Exemplo n.º 4
0
        public void Run(QuantumSimulator qsim)
        {
            var initials = new Result[] { Result.Zero, Result.One };

            foreach (var initial in initials)
            {
                var res = TestSet.Run(qsim, 1000, initial).Result;
                var(numZeros, numOnes) = res;
                Console.WriteLine($"{initial,-4}-> Zeros: {numZeros,-4}, Ones: {numOnes,-4}");
            }
        }
Exemplo n.º 5
0
    // Run a series of tests with different table and collection styles.
    bool RunTest()
    {
        // Number of nodes we'll allocate in each run (we could take this as an argument instead).
        int numNodes = 10000;

        // Run everything under an exception handler since test errors are reported as exceptions.
        try
        {
            // Run a pass with each table style. For each style run through the collection styles in the order
            // None, Alternate, Random and All. This sequence is carefully selected to remove progressively
            // more nodes from the array (since, within a given TestSet instance, once a node has actually
            // been collected it won't be resurrected for future runs).

            TestSet ts1 = new TestSet(TableStyle.Unconnected, numNodes);
            ts1.Run(CollectStyle.None);
            ts1.Run(CollectStyle.Alternate);
            ts1.Run(CollectStyle.Random);
            ts1.Run(CollectStyle.All);

            TestSet ts2 = new TestSet(TableStyle.ForwardLinked, numNodes);
            ts2.Run(CollectStyle.None);
            ts2.Run(CollectStyle.Alternate);
            ts2.Run(CollectStyle.Random);
            ts2.Run(CollectStyle.All);

            TestSet ts3 = new TestSet(TableStyle.BackwardLinked, numNodes);
            ts3.Run(CollectStyle.None);
            ts3.Run(CollectStyle.Alternate);
            ts3.Run(CollectStyle.Random);
            ts3.Run(CollectStyle.All);

            TestSet ts4 = new TestSet(TableStyle.Random, numNodes);
            ts4.Run(CollectStyle.None);
            ts4.Run(CollectStyle.Alternate);
            ts4.Run(CollectStyle.Random);
            ts4.Run(CollectStyle.All);
        }
        catch (TestException te)
        {
            // "Expected" errors.
            Console.WriteLine("TestError: {0}", te.Message);
            return false;
        }
        catch (Exception e)
        {
            // Totally unexpected errors (probably shouldn't see these unless there's a test bug).
            Console.WriteLine("Unexpected exception: {0}", e.GetType().Name);
            return false;
        }

        // If we get as far as here the test succeeded.
        return true;
    }