当前位置: 首页>>代码示例>>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;未经允许,请勿转载。