當前位置: 首頁>>代碼示例>>C#>>正文


C# Reference.GetEnumerator方法代碼示例

本文整理匯總了C#中System.Reference.GetEnumerator方法的典型用法代碼示例。如果您正苦於以下問題:C# Reference.GetEnumerator方法的具體用法?C# Reference.GetEnumerator怎麽用?C# Reference.GetEnumerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Reference的用法示例。


在下文中一共展示了Reference.GetEnumerator方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FSharpProjectSystemRemoveReferenceFailsMultipleMatches

        public void FSharpProjectSystemRemoveReferenceFailsMultipleMatches()
        {
            var project = new Mock<Project>();
            project.Setup(p => p.Properties.Item("FullPath").Value).Returns("x:\\");
            project.Setup(p => p.Name).Returns("Project");

            var reference1 = new Mock<Reference>();
            reference1.Setup(r => r.Name).Returns("AbC");

            var reference2 = new Mock<Reference>();
            reference2.Setup(r => r.Name).Returns("abc");

            var enumerableReferences = new Reference[] { reference1.Object, reference2.Object };

            var references = new Mock<References>();
            references.Setup(s => s.Item(It.IsAny<object>())).Returns((Reference)null);
            references.Setup(s => s.GetEnumerator()).Returns(enumerableReferences.GetEnumerator());

            var fileSystem = new Mock<IFileSystem>();
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(f => f.GetFileSystem("x:\\")).Returns(fileSystem.Object);

            var logger = new Mock<ILogger>();

            FSharpProjectSystem projectSystem = new FSharpProjectSystem(project.Object, fileSystemProvider.Object);
            projectSystem.Logger = logger.Object;

            // Act
            projectSystem.RemoveReferenceCore("aBc", references.Object);

            // Assert
            reference1.Verify(r => r.Remove(), Times.Never());
            reference2.Verify(r => r.Remove(), Times.Never());
            var message = String.Format(CultureInfo.CurrentCulture, VsResources.FailedToRemoveReference, "aBc");
            logger.Verify(l => l.Log(MessageLevel.Error, message));
        }
開發者ID:anurse,項目名稱:NuGet,代碼行數:36,代碼來源:VsProjectSystemTest.cs

示例2: FSharpProjectSystemRemoveReferenceFailedToFindMatch

        public void FSharpProjectSystemRemoveReferenceFailedToFindMatch()
        {
            var project = new Mock<Project>();
            project.Setup(p => p.Properties.Item("FullPath").Value).Returns("x:\\");
            project.Setup(p => p.Name).Returns("Project");

            var reference = new Mock<Reference>();
            reference.Setup(r => r.Name).Returns("AbC");

            var enumerableReferences = new Reference[] { reference.Object };

            var references = new Mock<References>();
            references.Setup(s => s.Item(It.IsAny<object>())).Returns((Reference)null);
            references.Setup(s => s.GetEnumerator()).Returns(enumerableReferences.GetEnumerator());

            var fileSystem = new Mock<IFileSystem>();
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(f => f.GetFileSystem("x:\\")).Returns(fileSystem.Object);

            var logger = new Mock<ILogger>();

            FSharpProjectSystem projectSystem = new FSharpProjectSystem(project.Object, fileSystemProvider.Object);
            projectSystem.Logger = logger.Object;

            // Act
            projectSystem.RemoveReferenceCore("aBcD", references.Object);

            // Assert
            reference.Verify(r => r.Remove(), Times.Never());
            logger.Verify(l => l.Log(MessageLevel.Warning, VsResources.Warning_FailedToFindMatchForRemoveReference, "aBcD"));
        }
開發者ID:anurse,項目名稱:NuGet,代碼行數:31,代碼來源:VsProjectSystemTest.cs


注:本文中的System.Reference.GetEnumerator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。