Пример #1
0
        //----< test TestRequest serialization and deserialization >-----

        static private void testTestRequest()
        {
            // Serialize and Deserialize TestRequest data structure
            "Testing Serialization of TestRequest data structure".title();
            TestElement te1 = new TestElement();

            te1.testName = "test1";
            te1.addDriver("td1.dll");
            te1.addCode("tc1.dll");
            te1.addCode("tc2.dll");
            TestElement te2 = new TestElement();

            te2.testName = "test2";
            te2.addDriver("td2.dll");
            te2.addCode("tc3.dll");
            te2.addCode("tc4.dll");
            TestRequest tr = new TestRequest();

            tr.author = "Jim Fawcett";
            tr.tests.Add(te1);
            tr.tests.Add(te2);
            string trXml = tr.ToXml();

            Console.Write("\n  Serialized TestRequest data structure:\n\n  {0}\n", trXml);

            "Testing Deserialization of TestRequest from XML".title();
            TestRequest newRequest = trXml.FromXml <TestRequest>();
            string      typeName   = newRequest.GetType().Name;

            Console.Write("\n  deserializing xml string results in type: {0}\n", typeName);
            Console.Write(newRequest);
            Console.WriteLine();

            // Create and Parse TestRequest message
            "Testing Creation and Parsing of TestRequest Message".title();
            Message msg = new Message();

            msg.to     = "TH";
            msg.from   = "CL";
            msg.type   = "basic";
            msg.author = "Fawcett";
            Console.Write("\n  base message:\n    {0}", msg.ToString());
            msg.show();

            Console.Write("\n  Creating Message using TestRequest data structure\n");
            Message rqstMsg = new Message();

            rqstMsg.author = "Fawcett";
            rqstMsg.to     = "localhost:8080";
            rqstMsg.from   = "localhost:8091";
            rqstMsg.type   = "TestRequest";
            rqstMsg.time   = DateTime.Now;
            rqstMsg.body   = tr.ToXml();
            rqstMsg.show();
            Console.Write("\n  retrieving testRequest object:");
            TestRequest newTrq = rqstMsg.body.FromXml <TestRequest>();

            Console.Write("\n{0}\n", newTrq);
        }
Пример #2
0
        /*----< make mock test request, for test executive use >------*/

        private TestRequest makeTestRequest(int i)
        {
            TestElement te = new TestElement();

            if (i == 0)
            {
                te.testName    = "Test1";
                te.buildTool   = "MSBuild";
                te.buildConfig = "Test1.csproj";
                te.addCode("Test1_Interfaces.cs");
                te.addCode("Test1_TestedLib.cs");
                te.addCode("Test1_TestedLibDependency.cs");
                te.addCode("Test1_TestLib.cs");
            }
            else if (i == 1)
            {
                te.testName    = "Test2";
                te.buildTool   = "MSBuild";
                te.buildConfig = "Test2.csproj";
                te.addCode("Test2_Interfaces.cs");
                te.addCode("Test2_TestedLib.cs");
                te.addCode("Test2_TestLib.cs");
            }

            TestRequest tr = new TestRequest();

            tr.author = "Kaiqi Zhang";
            tr.tests.Add(te);

            return(tr);
        }
Пример #3
0
        /*----< add a new test to the build request structure >-------*/

        private void btnAddToRequest_Click(object sender, RoutedEventArgs e)
        {
            if (tr == null)
            {
                tr        = new TestRequest();
                tr.author = "Kaiqi Zhang";
            }

            TestElement te = new TestElement();

            te.buildTool = "MSBuild";

            // build config xml
            string configFile = "";

            foreach (var item in fileListBox.SelectedItems)
            {
                string fileName = (string)item;
                if (System.IO.Path.GetExtension(fileName) == ".csproj")
                {
                    configFile = fileName;
                }
            }
            if (configFile == "")
            {
                MessageBox.Show("Please select one BuildConfig file (*.csproj).", "Add to Request",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            te.buildConfig = configFile;
            te.testName    = System.IO.Path.GetFileNameWithoutExtension(configFile);

            // cs files
            foreach (var item in fileListBox.SelectedItems)
            {
                string fileName = (string)item;
                if (System.IO.Path.GetExtension(fileName) == ".cs")
                {
                    te.addCode(fileName);
                }
            }

            tr.tests.Add(te);

            requestTextBox.Text = tr.ToXml();
        }