Пример #1
0
        /// <summary>
        /// Add Test Group information to document
        /// </summary>
        /// <param name="myDocument">Document</param>
        /// <param name="Tests">Tests</param>
        private void AddTestGroupInfo(Document myDocument, ONVIF_TestCases.TestCases_Class.TestGroup_Type Tests)
        {
            myDocument.NewPage();
            Chapter aChapter;

            // go through each test suite and record all the info
            if (Tests.Name != null)
            {
                Paragraph p0 = new Paragraph(new Chunk(Tests.Name + "\n\n", FontFactory.GetFont(FontFactory.TIMES, 18)));
                //p0.Alignment = Element.ALIGN_CENTER;
                //myDocument.Add(p0);


                aChapter = new Chapter(p0, 8);
                aChapter.BookmarkTitle = Tests.Name;
            }
            else
            {
                Paragraph p0 = new Paragraph(new Chunk("ONVIF TEST" + "\n\n", FontFactory.GetFont(FontFactory.TIMES, 18)));

                aChapter = new Chapter(p0, 1);
                aChapter.BookmarkTitle = Tests.Name;
            }
            aChapter.NumberDepth = 0;
            myDocument.Add(aChapter);
            if (Tests.Group != null)
            {
                foreach (ONVIF_TestCases.TestCases_Class.TestSuite_Type Suite in Tests.Group)
                {
                    AddTestSuiteInfo(myDocument, Suite, ref aChapter);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Build index page
        /// </summary>
        /// <param name="myDocument">Document</param>
        /// <param name="Tests">Tests</param>
        private void BuildIndex(Document myDocument, ONVIF_TestCases.TestCases_Class.TestGroup_Type Tests)
        {
            myDocument.NewPage();

            Paragraph p1 = new Paragraph(new Chunk("Tests\n", FontFactory.GetFont(FontFactory.TIMES, 16)));

            p1.Alignment = Element.ALIGN_CENTER;
            myDocument.Add(p1);

            foreach (ONVIF_TestCases.TestCases_Class.TestSuite_Type Suite in Tests.Group)
            {
                foreach (ONVIF_TestCases.TestCases_Class.Test_Type Test in Suite.Tests)
                {
                    string line   = String.Format("{0, -13} {1}\n", Test.Number, Test.Name);
                    Anchor anchor = new Anchor(line, FontFactory.GetFont(FontFactory.TIMES, 12));
                    anchor.Reference = "#" + Test.Name;
                    myDocument.Add(anchor);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Build a test summary and save it to the specified URL
        /// </summary>
        /// <param name="fileName">Save location for test summary</param>
        /// <param name="testHeader">Test summary header information</param>
        /// <param name="testData">Test summary data information</param>
        /// <returns>passed indicator</returns>
        public bool WriteTestSummary(string fileName, TestSummary_TestInfo_Type TestInfo, ONVIF_TestCases.TestCases_Class.TestGroup_Type Tests)
        {
            bool     passed     = false;
            Document myDocument = new Document(PageSize.A4);

            //ChapterCount = 1;

            // make sure the date has been set
            if (TestInfo.TestDateAndTime == "")
            {
                TestInfo.TestDateAndTime = String.Format("{0} @ {1}\n", System.DateTime.Now.ToShortDateString(), System.DateTime.Now.ToLongTimeString());
            }


            if (fileName.Contains("verbose"))
            {
                verboseOutput = true;
            }
            else
            {
                verboseOutput = false;
            }


            try
            {
                // create a new instance of the results file
                PdfWriter.GetInstance(myDocument, new FileStream(fileName, FileMode.Create));

                myDocument.Open();

                // build the footer with the ONVIF required information
                HeaderFooter footer = new HeaderFooter(new Phrase("Device - " + TestInfo.Device_Model + " " + TestInfo.TestDateAndTime + " ONVIF Test Report Page: "), true);
                footer.Border     = Rectangle.NO_BORDER;
                footer.Alignment  = Element.ALIGN_CENTER;
                myDocument.Footer = footer;

                BuildCoverPage(myDocument, TestInfo);

                // add summary
                BuildSummary(myDocument, Tests);

                // add index
                if (CreateIndex)
                {
                    BuildIndex(myDocument, Tests);
                }

                // add test data
                AddTestGroupInfo(myDocument, Tests);
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
                passed = false;
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
                passed = false;
            }

            // don't forget to close the file
            myDocument.Close();

            return(passed);
        }
Пример #4
0
        /// <summary>
        /// Build Test summary
        /// </summary>
        /// <param name="myDocument">Document</param>
        /// <param name="Tests">Tests</param>
        private void BuildSummary(Document myDocument, ONVIF_TestCases.TestCases_Class.TestGroup_Type Tests)
        {
            myDocument.NewPage();
            int testCount, optional_Skipped, manditory_Skipped;
            int testsRan, testsPassed, testsFailed;

            int optionalCount, optionalFailed, optionalPassed;

            testCount         = 0;
            optional_Skipped  = 0;
            manditory_Skipped = 0;
            //marked_Failed = 0;
            //marked_Passed = 0;

            testsRan    = 0;
            testsPassed = 0;
            testsFailed = 0;

            optionalCount  = 0;
            optionalFailed = 0;
            optionalPassed = 0;

            Paragraph p0 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.TIMES, 16)));

            p0.Add("ONVIF Test Summary\n");
            p0.Alignment = Element.ALIGN_CENTER;
            myDocument.Add(p0);

            if (!Tests.ONVIF_Conformace_Test)
            {
                Paragraph p1 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.TIMES, 16)));
                p1.Add("THIS IS NOT A VALID ONVIF CONFORMANCE TEST\n\n");
                p1.Alignment = Element.ALIGN_CENTER;
                myDocument.Add(p1);
            }

            Paragraph p_tests;

            foreach (ONVIF_TestCases.TestCases_Class.TestSuite_Type suite in Tests.Group)
            {
                foreach (ONVIF_TestCases.TestCases_Class.Test_Type test in suite.Tests)
                {
                    testCount++;

                    p_tests = new Paragraph(new Chunk(test.Name, FontFactory.GetFont(FontFactory.TIMES, 12)));

                    // if complete look at the details
                    if (test.TestComplete)
                    {
                        // if it was a "skipped" test it isn't valid
                        if (test.TestSkipped)
                        {
                            // if this test wasn't required don't count it against the user

                            if ((test.Compliance == ONVIF_TestCases.TestCases_Class.TestCompliance.Must) ||
                                (test.Compliance == ONVIF_TestCases.TestCases_Class.TestCompliance.Must_if_Supported))
                            {
                                manditory_Skipped++;
                            }
                            else
                            {
                                optional_Skipped++;
                            }
                        }
                        else
                        {
                            testsRan++;

                            if (test.Compliance == ONVIF_TestCases.TestCases_Class.TestCompliance.Optional)
                            {
                                optionalCount++;
                                if (test.TestPassed)
                                {
                                    optionalPassed++;
                                }
                                else
                                {
                                    optionalFailed++;
                                }
                            }
                            else
                            {
                                if (test.TestPassed)
                                {
                                    testsPassed++;
                                }
                                else
                                {
                                    testsFailed++;
                                }
                            }
                        }
                    }
                    else
                    {
                    }
                }
            }


            Paragraph p2 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.TIMES, 12)));

            p2.Add(String.Format("Test Count: {0}\n", testCount));
            p2.Add(String.Format("Manditory Tests Skipped: {0}\n", manditory_Skipped));
            p2.Add(String.Format("Optional Tests Skipped: {0}\n", optional_Skipped));
            p2.Add(String.Format("Tests Executed: {0}\n", testsRan));
            p2.Add(String.Format("Tests Passed:  {0}\n", testsPassed + optionalPassed));
            p2.Add(String.Format("Tests Failed:  {0}\n", testsFailed));


            if (optionalFailed > 0)
            {
                p2.Add(String.Format("Optional Tests Failed: {1}\n", "", optionalFailed));
            }

            p2.Add("\n");

            //p2.Add(String.Format("Test executed but marked \"FAILED\": {1}\n", "", marked_Failed));
            //p2.Add(String.Format("Test executed but marked \"PASSED\": {1}\n", "", marked_Passed));
            //p2.Add(String.Format("Tests executed but marked \"SKIPPED\": {1}\n", "", marked_Skipped));

            myDocument.Add(p2);

            // if not all tests were run this is not a valid conformance test
            if (testCount != (testsRan + optional_Skipped))
            {
                Paragraph p3 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.TIMES, 16)));
                p3.Add("NOT ALL TESTS RUN, NOT A VALID ONVIF CONFORMANCE TEST\n\n");
                p3.Alignment = Element.ALIGN_CENTER;
                myDocument.Add(p3);
            }
            else if (!Tests.ONVIF_Conformace_Test)
            {
                Paragraph p4 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.TIMES, 16)));
                p4.Add("THIS IS NOT A VALID ONVIF CONFORMANCE TEST\n\n");
                p4.Alignment = Element.ALIGN_CENTER;
                myDocument.Add(p4);
            }
        }