Пример #1
0
        static void Main(string[] args)
        {
            "Testing Test_TestRequest Class".title('=');
            Console.WriteLine();

            ///////////////////////////////////////////////////////////////
            // Serialize and Deserialize TestRequest data structure

            "Testing Serialization of TestRequest data structure".title();

            BuildElement te1 = new BuildElement();

            te1.testName = "test1";
            te1.addDriver("TestDriver.cs");
            te1.addCode("TestedOne.cs");
            te1.addCode("TestedTwo.cs");

            BuildElement te2 = new BuildElement();

            te2.testName = "test2";
            te2.addDriver("TestLib.cs");
            te2.addCode("TestedLib.cs");
            te2.addCode("TestedLibDependency.cs");
            te2.addCode("Interfaces.cs");

            BuildRequest tr = new BuildRequest();

            tr.author   = "Rahul Kadam";
            tr.dateTime = DateTime.Now.ToString();
            tr.tests.Add(te1);
            tr.tests.Add(te2);
            string trXml = tr.ToXml();

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

            string filePath = "../../../StorageRepoMock/TestRequests/TestRequest3.xml";

            Console.Write("\n  Saving TestRequest to xml file: {0}\n", filePath);
            File.WriteAllText(filePath, trXml);
            string trXml2 = File.ReadAllText(filePath);

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

            "Testing Deserialization of TestRequest from XML".title();

            BuildRequest newRequest = trXml.FromXml <BuildRequest>();
            string       typeName   = newRequest.GetType().Name;

            Console.Write("\n  deserializing xml string results in type: {0}\n", typeName);
            Console.Write(newRequest);
            Console.WriteLine();
        }
        /*----< Test Executive function >-----------*/
        private void Test_Exec(object sender, RoutedEventArgs e)
        {
            tabCntrl.SelectedItem = Builder;

            Console.Write("\n\n  Demonstrating Creating a Build Request ");
            Console.Write("\n -------------------------------------------");

            BuildRequest tr1 = new BuildRequest();
            BuildElement be1 = new BuildElement();

            be1.testName = "TestDriver1.cs";
            be1.addDriver("TestDriver1.cs");
            be1.addCode("TestDriver1TestFile1.cs");
            be1.addCode("TestDriver1TestFile2.cs");
            tr1.author   = "Rahul Kadam";
            tr1.dateTime = DateTime.Now.ToString();
            tr1.tests.Add(be1);
            BuildElement be2 = new BuildElement();

            be2.testName = "TestDriver2.cs";
            be2.addDriver("TestDriver2.cs");
            be2.addCode("TestDriver2TestFile1.cs");
            be2.addCode("TestDriver2TestFile2.cs");
            tr1.author   = "Rahul Kadam";
            tr1.dateTime = DateTime.Now.ToString();
            tr1.tests.Add(be2);

            Console.Write("\n  Build Request Created: ");
            Console.Write("\n  " + tr1.ToString());
            Console.Write("\n\n  Serializing Build Request to XML: ");
            string xmlstring = tr1.ToXml();

            Console.Write("\n\n" + xmlstring);

            List <string> repobuildrequestslist = new List <string>();

            repobuildrequestslist.Add("BuildRequest1.xml"); repobuildrequestslist.Add("BuildRequest2.xml");
            repobuildrequestslist.Add("BuildRequest3.xml"); repobuildrequestslist.Add("BuildRequest4.xml");

            foreach (string testRequest in repobuildrequestslist)
            {
                CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request);
                csndMsg.command     = "BuildRequest";
                csndMsg.author      = "Rahul Kadam";
                csndMsg.to          = repoMockAddress;
                csndMsg.from        = clientGUIAddress;
                csndMsg.testRequest = Path.GetFileName(testRequest);
                comm.postMessage(csndMsg);
                Console.Write("\n\n  Sending BuildRequest from GUI-Client to RepositoryMock ");
                csndMsg.show();
            }
        }
        /*----< Processes Add Test Button >-----------*/
        private void AddTest_Click(object sender, RoutedEventArgs e)
        {
            BuildElement te1 = new BuildElement();

            te1.testName = TestDriver.SelectedItem.ToString();
            te1.addDriver(TestDriver.SelectedItem.ToString());
            foreach (string test in TestFiles.SelectedItems)
            {
                te1.addCode(test);
            }
            tr.author   = "Rahul Kadam";
            tr.dateTime = DateTime.Now.ToString();
            tr.tests.Add(te1);
            Display.Text = tr.ToXml();
        }