public void WeMarkedEntryAsDeleted_ReportedAsDeletion() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1'/> <entry id='old2'/> </lift>" ; const string child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1' dateDeleted='2009-06-16T06:14:20Z'/> <entry id='old2'/> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, "header", "entry", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedConflictCount(0); listener.AssertExpectedChangesCount(1); listener.AssertFirstChangeType <XmlDeletionChangeReport>(); } }
public void NoChangesReported() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <AdditionalFields> <CustomField class='WfiWordform' key='WfiWordformCertified' name='Certified' type='Boolean' /> </AdditionalFields>"; // One deletion, one change, and one insertion, and one unchanged. const string child = @"<?xml version='1.0' encoding='utf-8'?> <AdditionalFields> <CustomField class='WfiWordform' key='WfiWordformCertified' name='Certified' type='Boolean' /> </AdditionalFields>"; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, null, "CustomField", "key"); differ.ReportDifferencesToListener(); listener.AssertExpectedConflictCount(0); listener.AssertExpectedChangesCount(0); } }
public void IdHasEntityDoesNotGenerateReports() { var parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id=""Id'dPrematurely_18d66025-59bc-4bd0-b59c-0f01ae09dede"" dateCreated='2009-09-14T10:02:26Z' dateModified='2009-09-14T10:26:21Z' guid='18d66025-59bc-4bd0-b59c-0f01ae09dede'> </entry> </lift>" ; var child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry dateCreated='2009-09-14T10:02:26Z' dateModified='2009-09-14T10:26:21Z' guid='18d66025-59bc-4bd0-b59c-0f01ae09dede' id=""Id'dPrematurely_18d66025-59bc-4bd0-b59c-0f01ae09dede""> </entry> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, "header", "entry", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(0); } }
public void NewEntryFromUs_Reported() { var child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1'/> <entry id='newGuy'/> <entry id='old2'/> </lift>" ; var parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1'/> <entry id='old2'/> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, "header", "entry", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(1); listener.AssertFirstChangeType <XmlAdditionChangeReport>(); } }
public void DeletionReport_Not_ProducedForDeletedAnnotationUsingNotesHandler() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <notes version='0'> <annotation guid='old1'/> <annotation guid='soonToBeGoner'/> </notes>" ; const string child = @"<?xml version='1.0' encoding='utf-8'?> <notes version='0'> <annotation guid='old1'/> </notes>" ; // Make sure the common differ code does produce the deletion report. using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, null, "annotation", "guid"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(1); listener.AssertFirstChangeType <XmlDeletionChangeReport>(); } // Now make sure the ChorusNotesFileHandler filters it out, and does not return it, // as per the original notes differ code. var notesHandler = (from handler in ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers where handler.GetType().Name == "ChorusNotesFileHandler" select handler).First(); using (var repositorySetup = new RepositorySetup("randy")) { repositorySetup.AddAndCheckinFile("notestest.ChorusNotes", parent); repositorySetup.ChangeFileAndCommit("notestest.ChorusNotes", child, "change it"); var hgRepository = repositorySetup.Repository; var allRevisions = (from rev in hgRepository.GetAllRevisions() orderby rev.Number.LocalRevisionNumber select rev).ToList(); var first = allRevisions[0]; var second = allRevisions[1]; var firstFiR = hgRepository.GetFilesInRevision(first).First(); var secondFiR = hgRepository.GetFilesInRevision(second).First(); var result = notesHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository); Assert.AreEqual(0, result.Count()); } }
public void GuidAttrBeforeIdAttrDoesNotGenerateReports() { var parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='fuzz-old1' guid='old1'/> </lift>" ; var child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry guid='old1' id='fuzz-old1'/> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, "header", "entry", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(0); } }
public void NewNestedEntryInChildReported() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <Reversal> <header> <ReversalIndex guid='c1ed46b8-e382-11de-8a39-0800200c9a66' > </ReversalIndex> </header> <ReversalIndexEntry guid='c1ed46b9-e382-11de-8a39-0800200c9a66'> </ReversalIndexEntry> </Reversal>"; const string child = @"<?xml version='1.0' encoding='utf-8'?> <Reversal> <header> <ReversalIndex guid='c1ed46b8-e382-11de-8a39-0800200c9a66' > </ReversalIndex> </header> <ReversalIndexEntry guid='c1ed46b9-e382-11de-8a39-0800200c9a66'> <Entries> <ReversalIndexEntry guid='c1ed46ba-e382-11de-8a39-0800200c9a66'> </ReversalIndexEntry> </Entries> </ReversalIndexEntry> </Reversal>"; File.WriteAllText(_commonFile.Path, parent); File.WriteAllText(_ourFile.Path, child); var differ = Xml2WayDiffer.CreateFromFiles(_commonFile.Path, _ourFile.Path, _eventListener, SharedConstants.Header, "ReversalIndexEntry", SharedConstants.GuidStr); differ.ReportDifferencesToListener(); _eventListener.AssertExpectedChangesCount(1); _eventListener.AssertFirstChangeType <XmlChangedRecordReport>(); }
public void GuidAttrBeforeIdAttrDoesNotGenerateReports() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <root> <item id='fuzz-old1' guid='old1'/> </root>" ; const string child = @"<?xml version='1.0' encoding='utf-8'?> <root> <item guid='old1' id='fuzz-old1'/> </root>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, null, "item", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(0); listener.AssertExpectedConflictCount(0); } }
public void NewEntryInChildReported() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <Anthropology> <header> <RnResearchNbk guid='c1ed6db2-e382-11de-8a39-0800200c9a66'> </RnResearchNbk> </header> <RnGenericRec guid='c1ed6db3-e382-11de-8a39-0800200c9a66'> </RnGenericRec> </Anthropology>"; const string child = @"<?xml version='1.0' encoding='utf-8'?> <Anthropology> <header> <RnResearchNbk guid='c1ed6db2-e382-11de-8a39-0800200c9a66'> </RnResearchNbk> </header> <RnGenericRec guid='c1ed6db3-e382-11de-8a39-0800200c9a66'> </RnGenericRec> <RnGenericRec guid='c1ed6db4-e382-11de-8a39-0800200c9a66'> </RnGenericRec> </Anthropology>"; File.WriteAllText(_commonFile.Path, parent); File.WriteAllText(_ourFile.Path, child); var differ = Xml2WayDiffer.CreateFromFiles(_commonFile.Path, _ourFile.Path, _eventListener, SharedConstants.Header, "RnGenericRec", SharedConstants.GuidStr); differ.ReportDifferencesToListener(); _eventListener.AssertExpectedChangesCount(1); _eventListener.AssertFirstChangeType <XmlAdditionChangeReport>(); }
public void SimpleChangeGeneratesReport() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <root> <item id='old1'/> </root>" ; const string child = @"<?xml version='1.0' encoding='utf-8'?> <root> <item id='old1' newAttr='newValue' /> </root>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, null, "item", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(1); listener.AssertFirstChangeType <XmlChangedRecordReport>(); listener.AssertExpectedConflictCount(0); } }
public void Deletion_WasTombstoneNowMissing_NoDeletionReport() { const string parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <item id='old1' dateDeleted='2009-06-16T06:14:20Z'/> <item id='old2'/> </lift>" ; const string child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <item id='old2'/> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, null, "item", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(0); listener.AssertExpectedConflictCount(0); } }
public void DuplicateIdInChildEntryEmitsWarning() { var parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1' dateDeleted='2009-06-16T06:14:20Z'/> <entry id='old2'/> </lift>" ; var child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1'/> <entry id='old1'/> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, "header", "entry", "id"); differ.ReportDifferencesToListener(); Assert.AreEqual(1, listener.Warnings.Count); } }
public void DeletionReport_Not_ProducedForDeletionInParentAndChild() { var parent = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1' dateDeleted='2009-06-16T06:14:20Z'/> <entry id='old2'/> </lift>" ; var child = @"<?xml version='1.0' encoding='utf-8'?> <lift version='0.10' producer='WeSay 1.0.0.0'> <entry id='old1' dateDeleted='2009-06-16T06:14:20Z'/> <entry id='old2'/> </lift>" ; using (var parentTempFile = new TempFile(parent)) using (var childTempFile = new TempFile(child)) { var listener = new ListenerForUnitTests(); var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path, listener, "header", "entry", "id"); differ.ReportDifferencesToListener(); listener.AssertExpectedChangesCount(0); } }