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


C# ListenerForUnitTests类代码示例

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


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

示例1: BothModifiedExampleFormTextWorksWithConflict

        public void BothModifiedExampleFormTextWorksWithConflict()
        {
            const string ancestor = @"<?xml version='1.0' encoding='utf-8'?>
            <lift version='0.10' producer='WeSay 1.0.0.0'>
            <entry id='test'  guid='F169EB3D-16F2-4eb0-91AA-FDB91636F8F6'>
            <sense id='123'>
             <example>
            <form lang='chorus'>
              <text>This is my example sentence.</text>
            </form>
              </example>
            </sense>
            </entry>
            </lift>";
            var ours = ancestor.Replace(@"This is my example", @"This was your example");
            var theirs = ancestor.Replace(@"This is my example", @"It's mine don't touch it.");

            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 LiftEntryMergingStrategy(mergeOrder),
                    false,
                    "header",
                    "entry", "guid");
                var result = File.ReadAllText(mergeOrder.pathToOurs);
                Assert.AreEqual(1, listener.Conflicts.Count);
                var warning = listener.Conflicts[0];
                Assert.AreEqual(typeof(XmlTextBothEditedTextConflict), warning.GetType(), warning.ToString());
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "//example/form");
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:35,代码来源:ExampleSentenceMergingTests.cs

示例2: TestSetup

		public override void TestSetup()
		{
			base.TestSetup();
			Mdc.UpgradeToVersion(MetadataCache.MaximumModelVersion);
			_eventListener = new ListenerForUnitTests();
			FieldWorksTestServices.SetupTempFilesWithName(SharedConstants.DataNotebookFilename, MetadataCache.MaximumModelVersion, out _ourFile, out _commonFile, out _theirFile);
		}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:7,代码来源:FieldWorksAnthropologyTypeHandlerTests.cs

示例3: 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

示例4: OneAddedOneTranslationOtherEditedFormText

        public void OneAddedOneTranslationOtherEditedFormText()
        {
            const string ancestor = @"<?xml version='1.0' encoding='utf-8'?>
            <lift version='0.10' producer='WeSay 1.0.0.0'>
            <entry id='test'  guid='F169EB3D-16F2-4eb0-91AA-FDB91636F8F6'>
            <sense id='123'>
             <example>
            <form lang='chorus'>
              <text>This is my example sentence.</text>
            </form>
              </example>
            </sense>
            </entry>
            </lift>";
            var ours = ancestor.Replace(@"This is my example", @"This was your example");
            var theirs = ancestor.Replace(@"</example>", @"<form lang='en'><text>hello new entry</text></form></example>");

            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 LiftEntryMergingStrategy(mergeOrder),
                    false,
                    "header",
                    "entry", "guid");
                var result = File.ReadAllText(mergeOrder.pathToOurs);
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "//example");
                AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath("//example/form", 2);
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:33,代码来源:ExampleSentenceMergingTests.cs

示例5: AllHadProperty_ButNothingElse

        public void AllHadProperty_ButNothingElse()
        {
            const string commonAncestor =
            @"<Lexicon>
            <LexEntry guid='c1ed94c5-e382-11de-8a39-0800200c9a66'>
            <Etymology>
            </Etymology>
            </LexEntry>
            </Lexicon>";

            const string ours =
            @"<Lexicon>
            <LexEntry guid='c1ed94c5-e382-11de-8a39-0800200c9a66'>
            <Etymology>
            </Etymology>
            </LexEntry>
            </Lexicon>";

            const string theirs =
            @"<Lexicon>
            <LexEntry guid='c1ed94c5-e382-11de-8a39-0800200c9a66'>
            <Etymology>
            </Etymology>
            </LexEntry>
            </Lexicon>";

            var listener = new ListenerForUnitTests();
            var merger = new XmlMerger(new NullMergeSituation())
            {
                EventListener = listener
            };
            merger.MergeStrategies.SetStrategy("Lexicon", ElementStrategy.CreateSingletonElement());

            var strat = ElementStrategy.CreateForKeyedElement("guid", false);
            strat.AttributesToIgnoreForMerging.Add("guid");
            merger.MergeStrategies.SetStrategy("LexEntry", strat);

            strat = ElementStrategy.CreateSingletonElement();
            strat.NumberOfChildren = NumberOfChildrenAllowed.ZeroOrOne;
            merger.MergeStrategies.SetStrategy("Etymology", strat);

            strat = ElementStrategy.CreateForKeyedElement("guid", false);
            strat.AttributesToIgnoreForMerging.Add("guid");
            merger.MergeStrategies.SetStrategy("LexEtymology", strat);

            XmlTestHelper.DoMerge(merger.MergeStrategies, merger.MergeSituation,
                                  commonAncestor, ours, theirs,
                                  new[] { "Lexicon/LexEntry/Etymology" },
                                  null,
                                  0, new List<Type>(),
                                  0, new List<Type>());
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:52,代码来源:MergeLimitedChildrenServiceTests.cs

示例6: 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

示例7: 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

示例8: 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

示例9: Conflict_TheirsAppearsInCollisionNote

        public void Conflict_TheirsAppearsInCollisionNote()
        {
            const string ours = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='lexicalformcollission' guid='c1ed1fa7-e382-11de-8a39-0800200c9a66' >
                            <lexical-unit>
                                <form lang='x'>
                                    <text>ours</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='lexicalformcollission' guid='c1ed1fa7-e382-11de-8a39-0800200c9a66' >
                            <lexical-unit>
                                <form lang='x'>
                                    <text>theirs</text>
                                </form>
                            </lexical-unit>
                        </entry>
                    </lift>";
            const string ancestor = @"<?xml version='1.0' encoding='utf-8'?>
                    <lift version='0.10' producer='WeSay 1.0.0.0'>
                        <entry id='lexicalformcollission' guid='c1ed1fa7-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 PoorMansMergeStrategy(),
                    false,
                    "header",
                    "entry", "guid");
                var result = File.ReadAllText(mergeOrder.pathToOurs);
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "lift/entry[@id='lexicalformcollission']");
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "lift/entry");//just one
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "lift/entry/field[@type='mergeConflict']/trait[@name = 'looserData']");
                XmlTestHelper.AssertXPathMatchesExactlyOne(result, "lift/entry/field[@type='mergeConflict' and @dateCreated]");
            }
        }
开发者ID:sillsdev,项目名称:chack,代码行数:46,代码来源:PoorMansMergingStrategyTests.cs

示例10: RangeSectionMergedCorrectly

 public void RangeSectionMergedCorrectly()
 {
     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 LiftEntryMergingStrategy(mergeOrder),
             false,
             "header",
             "entry", "guid");
         var result = File.ReadAllText(mergeOrder.pathToOurs);
         XmlTestHelper.AssertXPathMatchesExactlyOne(result, "lift/entry[@id='usOnly']");
         AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(@"lift/header/ranges/range", 4);
     }
 }
开发者ID:regnrand,项目名称:chorus,代码行数:18,代码来源:LiftHeaderMergingTests.cs

示例11: 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

示例12: 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

示例13: 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

示例14: RunServiceCore

        private static XmlNode RunServiceCore(string common, string ours, string theirs,
			MergeSituation mergeSituation, out XmlNode returnAncestorNode, out ListenerForUnitTests listener)
        {
            XmlNode ourNode;
            XmlNode theirNode;
            XmlNode ancestorNode;
            CreateThreeNodes(ours, out ourNode,
                             theirs, out theirNode,
                             common, out ancestorNode);
            returnAncestorNode = ancestorNode;

            var merger = GetMerger(mergeSituation, out listener);
            Assert.DoesNotThrow(() => MergeAtomicElementService.Run(merger, ref ourNode, theirNode, ancestorNode));

            return ourNode;
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:16,代码来源:MergeAtomicElementServiceTests.cs

示例15: GetMerger

 private static XmlMerger GetMerger(out ListenerForUnitTests listener, bool isAtomic)
 {
     var elementStrategy = new ElementStrategy(false)
         {
             IsAtomic = isAtomic
         };
     var merger = new XmlMerger(new NullMergeSituation());
     merger.MergeStrategies.SetStrategy("topatomic", elementStrategy);
     listener = new ListenerForUnitTests();
     merger.EventListener = listener;
     return merger;
 }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:12,代码来源:MergeAtomicElementServiceTests.cs


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