示例#1
0
        public void TestMethod1()
        {
            var htmlReporter = new ExtentHtmlReporter
                                   (@"C:\Users\partha\Desktop\dream.html");
            var repo = new ExtentReports();

            repo.AttachReporter(htmlReporter);
            var test = repo.CreateTest("parta");

            var wd = new ChromeDriver();

            wd.Url = "https://www.google.com/";
            HttpWebRequest req  = null;
            var            tags = wd.FindElementsByTagName("a");

            Dictionary <string, string> li = new Dictionary <string, string>();

            int hi = 0;

            Parallel.ForEach(tags, k =>
            {
                hi++;
                string h = k.GetAttribute("href");
                try
                {
                    req          = (HttpWebRequest)WebRequest.Create(h);
                    var response = (HttpWebResponse)req.GetResponse();
                    //test.Info(h + "- " + response.StatusCode.ToString());
                    li.Add(h, response.StatusDescription.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            });
            string[][] data = new string[li.Count][];
            int        i    = 0;

            try
            {
                foreach (KeyValuePair <string, string> item in li)
                {
                    data[i] = new string[2] {
                        item.Key, item.Value
                    };
                    i++;
                }
                test.Info(MarkupHelper.CreateTable(data));
                test.Info("rama");
            }
            catch (Exception) { }
            //ConvertDictionaryTo2dStringArray(li,test);
            repo.Flush();
            wd.Quit();
        }
        public void CaseLevelCounts()
        {
            var EdtDocumentCounts = EdtDocumentRepository.GetDocumentCountPerBatch();

            var tableData = new List <string[]>()
            {
                new string[] { "Batch", "Count of Documents" }
            };

            tableData.AddRange(EdtDocumentCounts.Select(x => new string[] { x.BatchName, x.DocumentCount.ToString() }));

            tableData.Add(new string[] { "Total", EdtDocumentCounts.Sum(x => x.DocumentCount).ToString() });

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(tableData.ToArray()));
        }
        public void NativeCountsAreEqualBetweenIdxAndEdtFileStore()
        {
            var cfsCount = EdtCfsService.GetDocumentCountForBatch();

            string[][] data = new string[][]
            {
                new string[] { "Item Evaluated", "Count of Documents" },
                new string[] { "Idx file", _idxDocumentCount.ToString() },
                new string[] { "Edt Central file store", cfsCount.ToString() }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            Assert.AreEqual(_idxDocumentCount, cfsCount, "File counts should be equal for Idx and Load file");
        }
示例#4
0
        public void FinalizeTest(string scenarioTitle, ExtentTest lastStep, string[,] tableData = null, string screenshotBase64 = null)
        {
            if (screenshotBase64 != null)
            {
                lastStep
                .AddScreenCaptureFromBase64String(screenshotBase64, scenarioTitle);
            }

            if (tableData != null)
            {
                var markupTable = MarkupHelper.CreateTable(tableData);

                lastStep
                .Log(Status.Info, markupTable.GetMarkup());
            }
        }
示例#5
0
        private void PrintStats(long different, long matched, long documentsInIdxButNotInEdt, long documentsInEdtButNotIdx, long idxMissingField, long unexpectedErrors, long populated, long total)
        {
            string[][] data = new string[][] {
                new string[] { "<b>Comparison Statistics:</b>" },
                new string[] { "Statistic", "Count" },
                new string[] { "Differences", different.ToString() },
                new string[] { "Matched", matched.ToString() },
                new string[] { "Idx document(s) incorrectly without a value in Edt", documentsInIdxButNotInEdt.ToString() },
                new string[] { "Edt document(s) incorrectly have a value when Idx is null", documentsInEdtButNotIdx.ToString() },
                new string[] { "Idx document(s) not populated for field under test (and EDt is also null)", idxMissingField.ToString() },
                new string[] { "Unexpected Errors during processing", unexpectedErrors.ToString() },
                new string[] { "Edt documents(s) populated with a value", populated.ToString() },
                new string[] { "Total Idx records sampled", total.ToString() }
            };

            TestLogger.Info(MarkupHelper.CreateTable(data));
        }
        public void NativeCountsAreEqualBetweenIdxAndQuarantineFolder()
        {
            int lppDocCount    = EdtDocumentRepository.GetDocumentQuarantineDocumentCount();
            int idxLppDocCount = new IdxDocumentsRepository().GetNumberOfLppDocs();

            string[][] data =
            {
                new[] { "Item Evaluated",    "Count of LPP Documents"  },
                new[] { "Idx file",          idxLppDocCount.ToString() },
                new[] { "Quarantine Folder", lppDocCount.ToString()    }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            Assert.AreEqual(lppDocCount, idxLppDocCount,
                            "File counts should be equal between IDX and EDT Quarantine folder");
        }
        public void TextCountsAreEqualBetweenIdxAndEdtFileStore()
        {
            //For each Document in Batch, Count where Body is not null
            var edtDocsWithBody = EdtDocumentRepository.GetDocuentNumbersWithABody();

            //compare against Text count in microfocus dir
            var edtIds          = EdtDocumentRepository.GetDocumentNumbers();
            var textFileDocsIds = Directory
                                  .GetFiles(Settings.MicroFocusStagingDirectoryTextPath, "*.txt", SearchOption.AllDirectories)
                                  .Select(x => GetDocumentIdFromFilePath(x)).Where(x => edtIds.Contains(x));

            var mircoFocusDocCount = textFileDocsIds.Count();

            //output counts
            string[][] data =
            {
                new[] { "Item Evaluated",            "Count of Documents"               },
                new[] { "MicroFocus Export text(s)", mircoFocusDocCount.ToString()      },
                new[] { "Edt Document.Body",         edtDocsWithBody.Count().ToString() }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            if (mircoFocusDocCount != edtDocsWithBody.Count())
            {
                //output diff list
                var outputFile = Path.Combine(Settings.ReportingDirectory, "TextContentMissing.csv");
                using (var sw = new StreamWriter(outputFile))
                {
                    var missingBodies = textFileDocsIds.Where(x => !edtDocsWithBody.Contains(x));
                    foreach (var missing in missingBodies)
                    {
                        sw.WriteLine(missing);
                    }

                    TestLogger.Info($"List of Ids without body output to: {new FileInfo(outputFile).FullName}");
                }
            }

            Assert.AreEqual(mircoFocusDocCount, edtDocsWithBody.Count(),
                            "File counts should be equal for Microfocus load and EDT");
        }
        public void DatabaseDocumentsCountsAreEqualBetweenIdxAndEdtDatabase()
        {
            var EdtDocumentCount = EdtDocumentRepository.GetDocumentCount();

            string[][] data = new string[][]
            {
                new string[] { "Item Evaluated", "Count of Documents" },
                new string[] { "Idx file", _idxDocumentCount.ToString() },
                new string[] { "Edt Database", EdtDocumentCount.ToString() }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            if (_idxDocumentCount != EdtDocumentCount)
            {
                PrintOutIdDiffs();
            }

            Assert.AreEqual(_idxDocumentCount, EdtDocumentCount, "File counts should be equal for Idx and Load file");
        }
 public void LogResponse(IRestResponse response)
 {
     try
     {
         string[,] a = new string[6, 2] {
             { "Response Uri", response.ResponseUri.OriginalString },
             { "Status Code", ((int)response.StatusCode).ToString() },
             { "Status", response.StatusDescription },
             { "Error Message", response.ErrorMessage },
             { "Server", response.Server },
             { "Protocol", response.ProtocolVersion.ToString() }
         };
         IMarkup m = MarkupHelper.CreateTable(a);
         test.Log(Status.Info, "Response Details:");
         test.Log(Status.Info, m);
     }
     catch (Exception e)
     {
         test.Log(Status.Error, e.Message);
     }
 }
 public void LogRequest(System.Uri url, String Method)
 {
     try
     {
         string[,] a = new string[6, 2] {
             { "Full URL", url.AbsoluteUri },
             { "Protocol", url.Scheme },
             { "Port", url.Port.ToString() },
             { "Host", url.DnsSafeHost },
             { "Local Path", url.LocalPath },
             { "Method", Method }
         };
         IMarkup m = MarkupHelper.CreateTable(a);
         test.Log(Status.Info, "Request Details:");
         test.Log(Status.Info, m);
     }
     catch (Exception e)
     {
         test.Log(Status.Error, e.Message);
     }
 }
        public void RedactedCountsAreEqualBetweenRedactionLoadFile()
        {
            int edtRedactionCount = 0;
            int redactionDocCount = 0;

            if (!string.IsNullOrWhiteSpace(Settings.RedactionsFilePath))
            {
                edtRedactionCount = EdtDocumentRepository.GetDocumentRedactedDocumentCount();
                redactionDocCount = new RedactionLoadFileReader(Settings.RedactionsFilePath).GetRecordCount();
            }

            string[][] data =
            {
                new[] { "Item Evaluated",      "Count of LPP Documents"     },
                new[] { "Redaction Load file", redactionDocCount.ToString() },
                new[] { "Document Table",      edtRedactionCount.ToString() }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            Assert.AreEqual(redactionDocCount, edtRedactionCount,
                            "File counts should be equal between Redaction Load files and EDT");
        }
示例#12
0
        public void InsertReportingSteps(ScenarioContext scenarioContext)
        {

            //ExtentReport >> Fill out report information based on Test Results
            var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString();

            ScenarioBlock scenarioBlock = scenarioContext.CurrentScenarioBlock;

            switch (scenarioBlock)
            {
                case ScenarioBlock.Given:
                    if (scenarioContext.TestError != null)
                    {
                        var screenshot = ((ITakesScreenshot)Driver.driver).GetScreenshot().AsBase64EncodedString;
                        var mediaEntity = MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, ScenarioStepContext.Current.StepInfo.Text).Build();
                        scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(scenarioContext.TestError.InnerException, mediaEntity);
                    }
                    else
                    {
                        scenario.CreateNode<Given>(scenarioContext.StepContext.StepInfo.Text);
                        string[,] data = new string[2,2];
                        data[0,0] = "Field 1";
                        data[0,1] = "Field 2";
                        data[1,0] = "data1";
                        data[1,1] = "data2";
                        IMarkup m = MarkupHelper.CreateTable(data);
                        scenario.Info(m);
                    }
                    break;
                case ScenarioBlock.When:
                    if (scenarioContext.TestError != null)
                    {
                        var screenshot = ((ITakesScreenshot)Driver.driver).GetScreenshot().AsBase64EncodedString;
                        var mediaEntity = MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, ScenarioStepContext.Current.StepInfo.Text).Build();
                        scenario.CreateNode<When>(ScenarioStepContext.Current.StepInfo.Text).Fail(scenarioContext.TestError.InnerException,mediaEntity);
                    }
                    else
                    {

                        scenario.CreateNode<And>(scenarioContext.StepContext.StepInfo.Text);
                        string[,] data = new string[2, 2];
                        data[0, 0] = "Field 1";
                        data[0, 1] = "Field 2";
                        data[1, 0] = "data1";
                        data[1, 1] = "data2";
                        IMarkup m = MarkupHelper.CreateTable(data);
                        scenario.Info(m);
                        var screenshot = ((ITakesScreenshot)Driver.driver).GetScreenshot().AsBase64EncodedString;
                        //  var mediaEntity = MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, ScenarioStepContext.Current.StepInfo.Text).Build();
                        scenario.CreateNode<When>(scenarioContext.StepContext.StepInfo.Text);
                            //.Pass(scenarioContext.StepContext.StepInfo.MultilineText, mediaEntity);

                    }
                    break;
                case ScenarioBlock.Then:
                    if (scenarioContext.TestError != null)
                    {
                        //screenshot in the Base64 format
                        var screenshot = ((ITakesScreenshot)Driver.driver).GetScreenshot().AsBase64EncodedString;
                        var mediaEntity = MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, ScenarioStepContext.Current.StepInfo.Text).Build();

                        scenario.CreateNode<Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(scenarioContext.TestError.Message,mediaEntity);
                    }
                    else
                    {
                        scenario.CreateNode<Then>(scenarioContext.StepContext.StepInfo.Text);

                    }
                    break;
                default:
                    if (scenarioContext.TestError != null)
                    {
                        var screenshot = ((ITakesScreenshot)Driver.driver).GetScreenshot().AsBase64EncodedString;
                        var mediaEntity = MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, ScenarioStepContext.Current.StepInfo.Text).Build();
                        scenario.CreateNode<And>(ScenarioStepContext.Current.StepInfo.Text).Fail(scenarioContext.TestError.InnerException, mediaEntity);
                    }
                    else
                    {
                        scenario.CreateNode<And>(scenarioContext.StepContext.StepInfo.Text);
                        string[,] data = new string[2, 2];
                        data[0, 0] = "Field 1";
                        data[0, 1] = "Field 2";
                        data[1, 0] = "data1";
                        data[1, 1] = "data2";
                        IMarkup m = MarkupHelper.CreateTable(data);
                        scenario.Info(m);
                        var screenshot = ((ITakesScreenshot)Driver.driver).GetScreenshot().AsBase64EncodedString;
                        var mediaEntity = MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, ScenarioStepContext.Current.StepInfo.Text).Build();
                        scenario.CreateNode<When>(scenarioContext.StepContext.StepInfo.Text).Pass(scenarioContext.StepContext.StepInfo.MultilineText, mediaEntity);

                    }
                    break;
            }



        }
        public void Tags()
        {
            long idxUnpopulated           = 0;
            long edtUnexpectedlyPopulated = 0;
            long errors    = 0;
            long matched   = 0;
            long different = 0;


            var workbookRecords = AunWorkbookReader.Read();
            var allEdtTags      = EdtDocumentRepository.GetDocumentTags(_idxDocumentIds);

            foreach (var idxRecord in _idxSample)
            {
                var aunWorkbookIds = idxRecord.AllFields.Where(x => x.Key.Equals("AUN_WORKBOOK_NUMERIC"));
                var foundEdtValue  = allEdtTags.TryGetValue(idxRecord.DocumentId, out var relatedEdTags);

                if (aunWorkbookIds.Count() == 0)
                {
                    idxUnpopulated++;
                    ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxRecord.DocumentId, "AUN_WORKBOOK_NUMERIC field was not present for idx record"));

                    if (relatedEdTags != null && relatedEdTags.Count() > 0)
                    {
                        edtUnexpectedlyPopulated++;
                        ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxRecord.DocumentId, $"EDT has value(s) {string.Join(",", relatedEdTags)} when Idx record had no value"));
                    }

                    continue;
                }

                foreach (var aunWorkbookId in aunWorkbookIds)
                {
                    var foundWorkbookName = workbookRecords.TryGetValue(aunWorkbookId.Value, out var aunWorkbookName);

                    if (foundWorkbookName)
                    {
                        if (!foundEdtValue || (relatedEdTags != null && !relatedEdTags.Any(x => x != null && x.Equals(aunWorkbookName, System.StringComparison.InvariantCultureIgnoreCase))))
                        {
                            different++;
                            var edtLogValue = relatedEdTags != null?string.Join(";", relatedEdTags) : "none found";

                            ComparisonResults.Add(new Framework.Models.Reporting.ComparisonResult(idxRecord.DocumentId, edtLogValue, aunWorkbookName, aunWorkbookId.Value.ToString()));
                        }
                        else
                        {
                            matched++;
                        }
                    }
                    else
                    {
                        errors++;
                        ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxRecord.DocumentId, $"Couldnt convert aun workbook id {aunWorkbookId} to name"));
                    }
                }
            }

            var diffFile = PrintComparisonTables("Tags");

            TestLogger.Info($"Difference and error details written to: <a href=\"{diffFile}\">{diffFile}</a>");

            //print table of stats
            string[][] data = new string[][] {
                new string[] { "<b>Comparison Statistics:</b>" },
                new string[] { "Statistic", "Count" },
                new string[] { "Differences", different.ToString() },
                new string[] { "Matched", matched.ToString() },
                new string[] { "Unexpected Errors", errors.ToString() },
                new string[] { "Edt document(s) incorrectly have a value when Idx is null", edtUnexpectedlyPopulated.ToString() },
                new string[] { "Idx document(s) not populated for field under test (and EDt is also null)", idxUnpopulated.ToString() }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            Assert.Zero(different, $"Differences were seen between expected value and actual value");
            Assert.Zero(edtUnexpectedlyPopulated, "Edt was found to have field populated for instances where Idx was null");
            Assert.Zero(errors, "Expected errors encountered during processing");

            if (idxUnpopulated > 0)
            {
                TestLogger.Info($"The Idx was found to not have a value for field AUN_WORKBOOK_NUMERIC in {idxUnpopulated} documents/instances.");
            }
        }
        public void Locations()
        {
            long idxUnpopulated           = 0;
            long edtUnexpectedlyPopulated = 0;
            long errors    = 0;
            long matched   = 0;
            long different = 0;

            var allEdtLocations = EdtDocumentRepository.GetDocumentLocations(_idxDocumentIds);

            foreach (var idxDocument in _idxSample)
            {
                allEdtLocations.TryGetValue(idxDocument.DocumentId, out var edtLocation);

                if (string.IsNullOrWhiteSpace(edtLocation))
                {
                    different++;
                    ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxDocument.DocumentId, "Location not present in EDT"));
                }

                string group     = idxDocument.AllFields.SingleOrDefault(x => x.Key.Equals(Settings.LocationIdxFields[0])).Value;
                string custodian = idxDocument.AllFields.SingleOrDefault(x => x.Key.Equals(Settings.LocationIdxFields[1])).Value;
                string source    = idxDocument.AllFields.SingleOrDefault(x => x.Key.Equals(Settings.LocationIdxFields[2])).Value;

                string location = $@"{group}\{custodian}\{source}";

                idxDocument.AllFields.Where(c => c.Key.StartsWith(Settings.LocationIdxFields[3])).OrderBy(c => c.Key).ToList().ForEach(
                    c =>
                {
                    if (!string.IsNullOrWhiteSpace(c.Value) && !c.Value.Contains(".msg:"))
                    {
                        location += @"\" + c.Value.Replace(":", "-");
                    }
                });

                if (!location.Equals(edtLocation, StringComparison.InvariantCultureIgnoreCase))
                {
                    different++;
                    ComparisonResults.Add(new Framework.Models.Reporting.ComparisonResult(idxDocument.DocumentId, edtLocation, location, location));
                }
                else
                {
                    matched++;
                }
            }

            var diffFile = PrintComparisonTables("Locations");

            TestLogger.Info($"Difference and error details written to: <a href=\"{diffFile}\">Report\\{diffFile}</a>");

            //print table of stats
            string[][] data = new string[][] {
                new string[] { "<b>Comparison Statistics:</b>" },
                new string[] { "Statistic", "Count" },
                new string[] { "Differences", different.ToString() },
                new string[] { "Matched", matched.ToString() },
                new string[] { "Unexpected Errors", errors.ToString() },
                new string[] { "Edt document(s) incorrectly have a value when Idx is null", edtUnexpectedlyPopulated.ToString() },
                new string[] { "Idx document(s) not populated for field under test (and EDt is also null)", idxUnpopulated.ToString() }
            };

            TestLogger.Log(AventStack.ExtentReports.Status.Info, MarkupHelper.CreateTable(data));

            Assert.Zero(different, $"Differences were seen between expected value and actual value");
            Assert.Zero(edtUnexpectedlyPopulated, "Edt was found to have field populated for instances where Idx was null");
            Assert.Zero(errors, "Expected errors encountered during processing");
        }