public ComparisonResults CompareDirectories() { _comparisonResults = new ComparisonResults(); _comparisonResults.LeftResults = _comparer.LeftCompare(DirectoryComparerBaseInfo.LeftPath, DirectoryComparerBaseInfo.RightPath); _comparisonResults.RightResults = _comparer.RightCompare(DirectoryComparerBaseInfo.RightPath, DirectoryComparerBaseInfo.LeftPath); return(_comparisonResults); }
public void CompareLogicCompareObjectsSame() { ComparisonResults res = (new CompareLogic()).Compare(new ComplexTestObject(), new ComplexTestObject()); Assert.True(res.DifferencesCount.Equals(0), "The JObjects should not have any differences and the count should be zero"); Assert.True(res.AreEqual, "The JObjects have different key names"); }
public void OutputResults(ComparisonResults comparisonResults, ComparisonSettings settings) { foreach (var outputter in _outputters) { outputter.RemoveExistingResults(); outputter.AddTitle("Produced at: " + _timeStampService.GetTimeStamp()); outputter.OutputFileContentDiffs(comparisonResults.FilePairs, settings.OnlyShowDiffs, "File Comparsion"); outputter.OutputFolderDiffs(comparisonResults.FilesOnlyInLeft, "Files Missing From Right (" + settings.PathToCheckRight + ")"); outputter.OutputFolderDiffs(comparisonResults.FilesOnlyInRight, "Files Missing From Left (" + settings.PathToCheckLeft + ")"); } }
public void CompareLogicCompareObjectsDifferent() { var o1 = new ComplexTestObject(); var o2 = new ComplexTestObject(); o2.ListofComplexItems.RemoveAt(1); o2.ListofComplexItems.Add(new ComplexTestItem2()); CompareLogic compareLogic = new CompareLogic(); ComparisonResults res = compareLogic.Compare(o1, o2); Assert.True(!res.AreEqual, "The JObjects are different"); }
private void AssertResults(string expectedResults, ComparisonResults actualResults) { StringBuilder sb = new StringBuilder(); for (short i = 0; i < actualResults.Results.Count; i++) { ComparisonResult result = actualResults.Results[i]; sb.AppendLine(result.Node + ":" + result.AreEqual); } string actualResultsStr = sb.ToString().Replace("\r\n", ""); Assert.AreEqual(expectedResults, actualResultsStr); }
public void Constructor_GoodValues_FilePairsPropertySet() { // Arrange // Act var comparisonResults = new ComparisonResults(_testFilePairs, new List <FileItem> { _fileItem1 }, new List <FileItem> { _fileItem2 }); // Assert comparisonResults.FilePairs.ShouldBeEquivalentTo(_testFilePairs); }
public void RunFileCheck(ComparisonSettings settings, IResultsOutputService outputService) { _fileListService.PopulateFileList(settings); // this is not quite the right place for this... var filePairs = _fileListService.GetFilesInBothSides(); PopulateFileHashValues(filePairs); var filesOnlyInLeft = _fileListService.GetFilesOnlyInLeftSide(); var filesOnlyInRight = _fileListService.GetFilesOnlyInRightSide(); var results = new ComparisonResults(filePairs, filesOnlyInLeft, filesOnlyInRight); outputService.OutputResults(results, settings); }
public void Constructor_GoodValues_FilesOnlyInRightPropertySet() { // Arrange var filesOnlyInRight = new List <FileItem> { _fileItem2 }; // Act var comparisonResults = new ComparisonResults(_testFilePairs, new List <FileItem> { _fileItem1 }, filesOnlyInRight); // Assert comparisonResults.FilesOnlyInRight.ShouldBeEquivalentTo(filesOnlyInRight); }
/// <summary> /// Will compare one schema with another. /// </summary> /// <returns>The to.</returns> /// <param name="thisSchemaData">This schema data.</param> /// <param name="schemaToCompareTo">Schema to compare to.</param> public static List <EntityTypeDifferences> CompareTo(this IDatabase thisSchemaData, IDatabase schemaToCompareTo) { CompareLogic compare = new CompareLogic(); ComparisonResults compareResult = new ComparisonResults(); var entityChanges = new List <EntityTypeDifferences>(); foreach (var entityName in thisSchemaData.Entities.Keys) { var entity = thisSchemaData.Entities[entityName]; if (schemaToCompareTo.ContainsKey(entityName)) { compare.Config.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All; compare.Config.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All; compareResult = compare.Compare(thisSchemaData.Entities[entityName], schemaToCompareTo[entityName]); if (!compareResult.AreEqual) { entityChanges.Add(new EntityTypeDifferences() { ChangeStatus = "changed", FileAction = TemplateFileAction.Update, EntityName = entityName, Differences = string.Join("\n", compareResult.DifferencesComparison.ToArray()) }); } } else { entityChanges.Add(new EntityTypeDifferences() { ChangeStatus = "new", FileAction = TemplateFileAction.Add, EntityName = entityName, Differences = string.Join("\n", compareResult.DifferencesComparison.ToArray()) }); } } foreach (var entityName in schemaToCompareTo.Entities.Keys) { if (!thisSchemaData.ContainsKey(entityName)) { entityChanges.Add(new EntityTypeDifferences() { ChangeStatus = "deleted", FileAction = TemplateFileAction.Delete, EntityName = entityName, Differences = string.Join("\n", compareResult.DifferencesComparison.ToArray()) }); } } entityChanges.Sort(); return(entityChanges); }
async void CompareAsync() { if (SelectedPlatforms != null && SelectedPlatforms.Count > 0) { List <IDbPlatform> list = new(); foreach (IDbPlatform platform in SelectedPlatforms) { list.Add(platform); } if (SelectedIDB.DB == LocalDB.OpenVGDB) { foreach (IDbPlatform platform in list) { Reporter.Report("Comparing " + platform.Releases.Count + " Robin " + platform.Title + " games to OVG."); await Task.Run(() => { CompareToOVGDB(platform); }); } } else { foreach (IDbPlatform idbPlatform in list) { Compares comparator = new(SelectedIDB.DB, idbPlatform); comparator.Title += "-" + ComparisonResults.Count; Reporter.Report("Comparing " + idbPlatform.Releases.Count + " Robin " + idbPlatform.Title + " games to " + Enum.GetName(typeof(LocalDB), SelectedIDB.DB) + "."); await Task.Run(() => { comparator.CompareToDB(Threshold, (SelectedIDB.HasRegions)); }); ComparisonResults.Add(comparator); } Reporter.Report("Finished"); } } }
private void backgroundWorkerDifference_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { progressBarCompare.Value = 80; Refresh(); if (ComparisonPathType == PathType.Line) { var editLine = new EditLine(Line1, Line2); editLine.Show(); } else { if (ComparisonPathType == PathType.ListItems) { ComparisonPathType = PathType.File; } var fileComparisonResults = new ComparisonResults ( ListFiles1, ListFiles2, DifferenceLines, startTime, txtPath1.Text, txtPath2.Text, ComparisonPathType, summary ); fileComparisonResults.WindowState = FormWindowState.Maximized; fileComparisonResults.Show(); } progressBarCompare.Value = 100; Refresh(); Cursor = Cursors.Default; Close(); }
public void ValidateFieldPopulation(StandardMapping mappingUnderTest) { long populated = 0; long different = 0; long documentsInIdxButNotInEdt = 0; long documentsInEdtButNotInIdx = 0; long idxUnfound = 0; long unexpectedErrors = 0; long matched = 0; long totalsampled = 0; //initiliase conversion service for field under test _idxToEdtConversionService = new IdxToEdtConversionService(mappingUnderTest); TestLogger.Debug($"Using EDT database column for comparison: {_idxToEdtConversionService.MappedEdtDatabaseColumn}"); //Get var edtValues = GetEdtFieldValues(mappingUnderTest); //loop thru each sample document foreach (var idxDocument in _idxSample) { totalsampled++; var idxField = GetIdxFieldValue(idxDocument, mappingUnderTest); if (!edtValues.TryGetValue(idxDocument.DocumentId, out var edtValueForIdxRecord) && !string.IsNullOrEmpty(idxField)) { documentsInIdxButNotInEdt++; ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxDocument.DocumentId, "Document not found in Edt's document table")); } else { if (string.IsNullOrEmpty(idxField)) { if (!string.IsNullOrEmpty(edtValueForIdxRecord)) { documentsInEdtButNotInIdx++; ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxDocument.DocumentId, $"Edt had value {edtValueForIdxRecord} for field {mappingUnderTest.EdtName} when Idx had no value.")); } else { idxUnfound++; ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxDocument.DocumentId, $"Field { mappingUnderTest.IdxName } not found in Idx for document")); } } else { try { if (!string.IsNullOrEmpty(edtValueForIdxRecord)) { populated++; } var expectedEdtValue = _idxToEdtConversionService.ConvertValueToEdtForm(idxField); if (!edtValueForIdxRecord.Equals(expectedEdtValue, StringComparison.InvariantCultureIgnoreCase)) { different++; ComparisonResults.Add(new Framework.Models.Reporting.ComparisonResult(idxDocument.DocumentId, edtValueForIdxRecord, expectedEdtValue, idxField)); } else { matched++; } } catch (Exception ex) { unexpectedErrors++; var error = $"{ex.Message}<br></br>{ex.StackTrace}"; ComparisonErrors.Add(new Framework.Models.Reporting.ComparisonError(idxDocument.DocumentId, error)); } } } } PrintStats(different, matched, documentsInIdxButNotInEdt, documentsInEdtButNotInIdx, idxUnfound, unexpectedErrors, populated, totalsampled); if (ComparisonErrors.Count() > 0 || ComparisonResults.Count() > 0) { var diffFile = PrintComparisonTables(mappingUnderTest.EdtName); TestLogger.Info($"Difference and error details written to: <a href=\"{diffFile}\">{diffFile}</a>"); } Assert.Zero(different, $"Differences were seen between expected value and actual value for this Edt field {mappingUnderTest.EdtName}"); Assert.Zero(unexpectedErrors, $"Unexpected errors experienced during processing {mappingUnderTest.EdtName}"); Assert.Zero(documentsInIdxButNotInEdt, $"Idx documents were not found in EDT."); Assert.Zero(documentsInEdtButNotInIdx, "Edt was found to have field populated for instances where Idx was null"); if (idxUnfound > 0) { TestLogger.Info($"The Idx was found to not have a value for field {mappingUnderTest.IdxName} in {idxUnfound} documents/instances."); } if (populated == 0) { TestLogger.Info($"No sampled documents had the Edt field {mappingUnderTest.EdtName} populated."); } }
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"); }
public XmlComparer() { _results = new ComparisonResults(); _xmlDocA = new XmlDocument(); _xmlDocB = new XmlDocument(); }