当前位置: 首页>>代码示例>>C#>>正文


C# ListenerForUnitTests.AssertExpectedChangesCount方法代码示例

本文整理汇总了C#中ListenerForUnitTests.AssertExpectedChangesCount方法的典型用法代码示例。如果您正苦于以下问题:C# ListenerForUnitTests.AssertExpectedChangesCount方法的具体用法?C# ListenerForUnitTests.AssertExpectedChangesCount怎么用?C# ListenerForUnitTests.AssertExpectedChangesCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListenerForUnitTests的用法示例。


在下文中一共展示了ListenerForUnitTests.AssertExpectedChangesCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BothAddedHeaderButWithDifferentContentInEach

        public void BothAddedHeaderButWithDifferentContentInEach()
        {
            const string ancestor = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='parent' guid='c1ed1fa3-e382-11de-8a39-0800200c9a66' >
                            <lexical-unit>
                                <form lang='a'>
                                    <text>form parent</text>
                                </form>
                            </lexical-unit>
                         </entry>
                    </lift>";
            var alpha = ancestor.Replace("<entry id", "<header><description>alphastuff</description></header><entry id");
            var beta = ancestor.Replace("<entry id", "<header><ranges>betastuff</ranges></header><entry id");

            using (var oursTemp = new TempFile(alpha))
            using (var theirsTemp = new TempFile(beta))
            using (var ancestorTemp = new TempFile(ancestor))
            {
                var listener = new ListenerForUnitTests();
                var situation = new NullMergeSituation();
                var mergeOrder = new MergeOrder(oursTemp.Path, ancestorTemp.Path, theirsTemp.Path, situation) { EventListener = listener };
                XmlMergeService.Do3WayMerge(mergeOrder, new LiftEntryMergingStrategy(mergeOrder),
                    false,
                    "header",
                    "entry",
                    "guid");
                var result = File.ReadAllText(mergeOrder.pathToOurs);
                Assert.IsTrue(result.Contains("<header>"));
                Assert.IsTrue(result.Contains("<description>"));
                Assert.IsTrue(result.Contains("<ranges>"));
                listener.AssertExpectedChangesCount(2);
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:34,代码来源:FileLevelMergeTests.cs

示例2: BothAdded_ButNotTheSame_HasConflictForTheyWin_TheirChangeIsKept

 public void BothAdded_ButNotTheSame_HasConflictForTheyWin_TheirChangeIsKept()
 {
     var listener = new ListenerForUnitTests();
     XmlNode ours;
     XmlNode theirs;
     var resultNode = DoMerge(null, "<MyNewImmutableElemment />", "<TheirNewImmutableElemment />", new NullMergeSituationTheyWin(), listener, out ours, out theirs);
     Assert.IsNotNull(resultNode);
     Assert.AreEqual("<TheirNewImmutableElemment />", resultNode.OuterXml);
     listener.AssertExpectedChangesCount(0);
     listener.AssertExpectedConflictCount(1);
     listener.AssertFirstConflictType<BothAddedMainElementButWithDifferentContentConflict>();
     Assert.AreSame(theirs, resultNode);
     Assert.AreSame(ours, theirs);
 }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:14,代码来源:ImmutableElementMergeServiceTests.cs

示例3: AncestorNull_OursNull_TheirsNotNull_HasChangeReport_AndTheirsIsKeptInMerge

 public void AncestorNull_OursNull_TheirsNotNull_HasChangeReport_AndTheirsIsKeptInMerge()
 {
     var listener = new ListenerForUnitTests();
     XmlNode ours;
     XmlNode theirs;
     var resultNode = DoMerge(null, null, "<NewImmutableElemment />", new NullMergeSituation(), listener, out ours, out theirs);
     Assert.IsNotNull(resultNode);
     Assert.AreEqual("<NewImmutableElemment />", resultNode.OuterXml);
     listener.AssertExpectedChangesCount(1);
     listener.AssertFirstChangeType<XmlAdditionChangeReport>();
     listener.AssertExpectedConflictCount(0);
     Assert.AreSame(ours, theirs);
     Assert.AreSame(ours, resultNode);
 }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:14,代码来源:ImmutableElementMergeServiceTests.cs

示例4: DeletionReport_Not_ProducedForDeletedAnnotationUsingNotesHandler

        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());
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:47,代码来源:FileLevelDiffTests.cs

示例5: BothDidSameUpgrade

        public void BothDidSameUpgrade()
        {
            const string commonData = "{\"modelversion\": 7000044}";
            const string ourData = "{\"modelversion\": 7000046}";
            const string theirData = "{\"modelversion\": 7000046}";

            File.WriteAllText(_commonFile.Path, commonData);
            File.WriteAllText(_ourFile.Path, ourData);
            File.WriteAllText(_theirFile.Path, theirData);

            var listener = new ListenerForUnitTests();
            var mergeOrder = new MergeOrder(_ourFile.Path, _commonFile.Path, _ourFile.Path, new NullMergeSituation()) { EventListener = listener };
            FileHandler.Do3WayMerge(mergeOrder);
            var mergedData = File.ReadAllText(_ourFile.Path);
            Assert.AreEqual(ourData, mergedData);
            listener.AssertExpectedConflictCount(0);
            listener.AssertExpectedChangesCount(1);
            listener.AssertFirstChangeType<FieldWorksModelVersionUpdatedReport>();
        }
开发者ID:StephenMcConnel,项目名称:flexbridge,代码行数:19,代码来源:FieldWorksModelVersionFileHandlerTests.cs

示例6: GuidAttrBeforeIdAttrDoesNotGenerateReports

 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);
     }
 }
开发者ID:sillsdev,项目名称:chack,代码行数:21,代码来源:Xml2WayDifferTests.cs

示例7: Deletion_WasTombstoneNowMissing_NoDeletionReport

 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);
     }
 }
开发者ID:sillsdev,项目名称:chack,代码行数:22,代码来源:Xml2WayDifferTests.cs

示例8: CheckMergeResults

        public static void CheckMergeResults(string mergedResults, ListenerForUnitTests eventListener,
			IEnumerable<string> xpathQueriesThatMatchExactlyOneNode, IEnumerable<string> xpathQueriesThatReturnNull,
			int expectedConflictCount, List<Type> expectedConflictTypes,
			int expectedChangesCount, List<Type> expectedChangeTypes)
        {
            if (xpathQueriesThatMatchExactlyOneNode != null)
            {
                foreach (var query in xpathQueriesThatMatchExactlyOneNode)
                    AssertXPathMatchesExactlyOne(mergedResults, query);
            }

            if (xpathQueriesThatReturnNull != null)
            {
                foreach (var query in xpathQueriesThatReturnNull)
                    AssertXPathIsNull(mergedResults, query);
            }

            eventListener.AssertExpectedConflictCount(expectedConflictCount);
            expectedConflictTypes = expectedConflictTypes ?? new List<Type>();
            Assert.AreEqual(expectedConflictTypes.Count, eventListener.Conflicts.Count,
                            "Expected conflict count and actual number found differ.");
            for (var idx = 0; idx < expectedConflictTypes.Count; ++idx)
                Assert.AreSame(expectedConflictTypes[idx], eventListener.Conflicts[idx].GetType());

            eventListener.AssertExpectedChangesCount(expectedChangesCount);
            expectedChangeTypes = expectedChangeTypes ?? new List<Type>();
            Assert.AreEqual(expectedChangeTypes.Count, eventListener.Changes.Count,
                            "Expected change count and actual number found differ.");
            for (var idx = 0; idx < expectedChangeTypes.Count; ++idx)
                Assert.AreSame(expectedChangeTypes[idx], eventListener.Changes[idx].GetType());
        }
开发者ID:sillsdev,项目名称:chack,代码行数:31,代码来源:XmlTestHelper.cs

示例9: WeDeleted_HasChangeReport

 public void WeDeleted_HasChangeReport()
 {
     var listener = new ListenerForUnitTests();
     XmlNode ours;
     XmlNode theirs;
     var resultNode = DoMerge("<OriginalImmutableElemment />", null, "<TheirImmutableElemment />", new NullMergeSituation(), listener, out ours, out theirs);
     Assert.IsNull(resultNode);
     Assert.IsNull(ours);
     Assert.IsNotNull(theirs);
     listener.AssertExpectedChangesCount(1);
     listener.AssertFirstChangeType<XmlDeletionChangeReport>();
     listener.AssertExpectedConflictCount(0);
 }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:13,代码来源:ImmutableElementMergeServiceTests.cs

示例10: ShouldHaveNoChanges

        public void ShouldHaveNoChanges()
        {
            const string commonData = "{\"modelversion\": 7000037}";
            const string ourData = "{\"modelversion\": 7000037}";
            const string theirData = "{\"modelversion\": 7000037}";

                File.WriteAllText(_commonFile.Path, commonData);
                File.WriteAllText(_ourFile.Path, ourData);
                File.WriteAllText(_theirFile.Path, theirData);

                var listener = new ListenerForUnitTests();
                var mergeOrder = new MergeOrder(_ourFile.Path, _commonFile.Path, _theirFile.Path, new NullMergeSituation()) { EventListener = listener };
                FileHandler.Do3WayMerge(mergeOrder);
                var mergedData = File.ReadAllText(_ourFile.Path);
                Assert.AreEqual(ourData, mergedData);
                listener.AssertExpectedConflictCount(0);
                listener.AssertExpectedChangesCount(0);
        }
开发者ID:StephenMcConnel,项目名称:flexbridge,代码行数:18,代码来源:FieldWorksModelVersionFileHandlerTests.cs

示例11: NewStyle_DoomedByUsEditedByThem_HasOneConflict

        public void NewStyle_DoomedByUsEditedByThem_HasOneConflict()
        {
            // New Style means the deleted entry was really removed from the file, not just marked as deleted.
            const string ancestor = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='noChangesInEither' guid='c1ed1f9b-e382-11de-8a39-0800200c9a66' >
                            <lexical-unit>
                                <form lang='a'>
                                    <text>form a</text>
                                </form>
                            </lexical-unit>
                         </entry>
                        <entry id='doomedByUsEditedByThem' guid='c1ed1f9c-e382-11de-8a39-0800200c9a66' >
                            <sense>
                                 <gloss lang='a'>
                                    <text>original</text>
                                 </gloss>
                            </sense>
                        </entry>
                    </lift>";
            const string ours = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='noChangesInEither' guid='c1ed1f9b-e382-11de-8a39-0800200c9a66' >
                            <lexical-unit>
                                <form lang='a'>
                                    <text>form a</text>
                                </form>
                            </lexical-unit>
                         </entry>
                    </lift>";

            const string theirs = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='noChangesInEither' guid='c1ed1f9b-e382-11de-8a39-0800200c9a66' >
                            <lexical-unit>
                                <form lang='a'>
                                    <text>form a</text>
                                </form>
                            </lexical-unit>
                         </entry>
                        <entry id='doomedByUsEditedByThem' guid='c1ed1f9c-e382-11de-8a39-0800200c9a66' >
                            <sense>
                                 <gloss lang='a'>
                                    <text>newByThem</text>
                                 </gloss>
                            </sense>
                        </entry>

                    </lift>";

            var listener = new ListenerForUnitTests();
            using (var oursTemp = new TempFile(ours))
            using (var theirsTemp = new TempFile(theirs))
            using (var ancestorTemp = new TempFile(ancestor))
            {
                var situation = new NullMergeSituation();
                var mergeOrder = new MergeOrder(oursTemp.Path, ancestorTemp.Path, theirsTemp.Path, situation) { EventListener = listener };
                XmlMergeService.Do3WayMerge(mergeOrder, new DropTheirsMergeStrategy(),
                    false,
                    "header",
                    "entry", "guid");
                var result = File.ReadAllText(mergeOrder.pathToOurs);
                Assert.IsTrue(result.ToLower().Contains("utf-8"));
            }
            listener.AssertExpectedChangesCount(0);
            listener.AssertExpectedConflictCount(1);
            listener.AssertFirstConflictType<RemovedVsEditedElementConflict>();
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:68,代码来源:FileLevelMergeTests.cs

示例12: NewEntryFromUs_HasNoChangeReports

        public void NewEntryFromUs_HasNoChangeReports()
        {
            const string ancestor = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='commonOldie' guid='c1ecf897-e382-11de-8a39-0800200c9a66' />
                    </lift>";
            const string ours = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='ourNew' guid='c1ecf898-e382-11de-8a39-0800200c9a66' />
                        <entry id='commonOldie' guid='c1ecf897-e382-11de-8a39-0800200c9a66' />
                    </lift>";
            const string theirs = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='commonOldie' guid='c1ecf897-e382-11de-8a39-0800200c9a66' />
                    </lift>";

            using (var oursTemp = new TempFile(ours))
            using (var theirsTemp = new TempFile(theirs))
            using (var ancestorTemp = new TempFile(ancestor))
            {
                var listener = new ListenerForUnitTests();
                var situation = new NullMergeSituation();
                var mergeOrder = new MergeOrder(oursTemp.Path, ancestorTemp.Path, theirsTemp.Path, situation) { EventListener = listener };
                XmlMergeService.Do3WayMerge(mergeOrder, new DropTheirsMergeStrategy(),
                    false,
                    "header",
                    "entry", "guid");
                var result = File.ReadAllText(mergeOrder.pathToOurs);
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "lift/entry[@id='ourNew']");
                listener.AssertExpectedConflictCount(0);
                listener.AssertExpectedChangesCount(0);
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:33,代码来源:FileLevelMergeTests.cs

示例13: Merge_RealConflictPlusModDateConflict_ModDateNotReportedAsConflict

        public void Merge_RealConflictPlusModDateConflict_ModDateNotReportedAsConflict()
        {
            const string template = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='blah' guid='c1ed1f94-e382-11de-8a39-0800200c9a66' dateModified='theDate'>
                           <lexical-unit>
                                <form lang='a'>
                                    <text>theForm</text>
                                </form>
                            </lexical-unit>
                        </entry>
                    </lift>";

            // NB: dateModified is set to ignore for LiftEntryMergingStrategy, thus no conflict report.
            using (var oursTemp = new TempFile(template.Replace("theDate",		"2009-07-08T01:47:06Z").Replace("theForm", "1")))
            using (var theirsTemp = new TempFile(template.Replace("theDate",	"2009-07-09T01:47:05Z").Replace("theForm", "2")))
            using (var ancestorTemp = new TempFile(template.Replace("theDate",	"2009-07-09T01:47:04Z").Replace("theForm", "3")))
            {
                var listener = new ListenerForUnitTests();
                var situation = new NullMergeSituation();
                var mergeOrder = new MergeOrder(oursTemp.Path, ancestorTemp.Path, theirsTemp.Path, situation) { EventListener = listener };
                XmlMergeService.Do3WayMerge(mergeOrder, new LiftEntryMergingStrategy(mergeOrder),
                    false,
                    "header",
                    "entry", "guid");
                listener.AssertExpectedConflictCount(1);
                listener.AssertFirstConflictType<XmlTextBothEditedTextConflict>();
                listener.AssertExpectedChangesCount(0);
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:30,代码来源:FileLevelMergeTests.cs

示例14: XmlMergerCallsImmutableElementMergeServiceForImmutableElement

 public void XmlMergerCallsImmutableElementMergeServiceForImmutableElement()
 {
     var listener = new ListenerForUnitTests();
     var merger = new XmlMerger(new NullMergeSituation())
     {
         EventListener = listener
     };
     var elemStrat = new ElementStrategy(false)
         {
             IsImmutable = true
         };
     merger.MergeStrategies.SetStrategy("ImmutableElemment", elemStrat);
     var ancestor = CreateNode("<ImmutableElemment attr='originalvalue' />");
     var ours = CreateNode("<ImmutableElemment attr='ourvalue' />");
     var theirs = CreateNode("<ImmutableElemment attr='theirvalue' />");
     merger.MergeInner(ref ours, theirs, ancestor);
     Assert.AreSame(ancestor, ours);
     Assert.AreEqual("<ImmutableElemment attr=\"originalvalue\" />", ancestor.OuterXml);
     listener.AssertExpectedChangesCount(0);
     listener.AssertExpectedConflictCount(0);
 }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:21,代码来源:ImmutableElementMergeServiceTests.cs

示例15: AncestorIsEmptyFileAndBothAddedSameThingHasOneChangeReport

 public void AncestorIsEmptyFileAndBothAddedSameThingHasOneChangeReport()
 {
     const string data =
     @"<?xml version='1.0' encoding='utf-8'?>
     <data />";
     using (var ancestor = new TempFile())
     using (var ours = new TempFile())
     using (var theirs = new TempFile())
     {
         File.WriteAllText(ancestor.Path, "");
         File.WriteAllText(ours.Path, data);
         File.WriteAllText(theirs.Path, data);
         var listener = new ListenerForUnitTests();
         var merger = new XmlMerger(new NullMergeSituation())
             {
                 EventListener = listener
             };
         var result = merger.MergeFiles(ours.Path, theirs.Path, ancestor.Path);
         Assert.IsNotNull(result);
         listener.AssertExpectedChangesCount(1);
         listener.AssertFirstChangeType<XmlBothAddedSameChangeReport>();
         listener.AssertExpectedConflictCount(0);
     }
 }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:24,代码来源:XmlMergerTests.cs


注:本文中的ListenerForUnitTests.AssertExpectedChangesCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。