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


C# MockRepository.Of方法代码示例

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


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

示例1: EatArgumentsTest

        public void EatArgumentsTest()
        {
            // Arrange
            var expression = Mock.Of<ICSharpExpression>();
            var mockRep = new MockRepository(MockBehavior.Default);
            var args = new  TreeNodeCollection<ICSharpArgument>(mockRep.Of<ICSharpArgument>().Where(t => t.Value == expression).Take(10).ToArray());
            var snapshot = Mock.Of<ISnapshot>();
            var eater = new Mock<IEater>();
            var argumentsEater = new ArgumentsEater(eater.Object);

            // Act
            argumentsEater.Eat(snapshot, args);

            // Assert
            eater.Verify(t => t.Eat(snapshot, expression), Times.Exactly(10));
        }
开发者ID:KozhevnikovDmitry,项目名称:MockMetrics,代码行数:16,代码来源:ArgumentsEaterTests.cs

示例2: RepoTestMethod

        public void RepoTestMethod()
        {
            var repository = new MockRepository(MockBehavior.Default);

            ILoggerSomeDependency logger = repository.Of<ILoggerSomeDependency>()
                .Where(ld => ld.GetLoggerInstance == "GetLoggerInstance")
                .Where(ld => ld.GetApplicationDirectory() == "C:\\Windows\\Fenestra")
                .Where(ld => ld.GetDirectoryForDependencyByLoggerName
                (It.IsAny<string>()) == "C:\\Windows\\Temp")
                .First();

            Assert.That(logger.GetApplicationDirectory(), Is.EqualTo("C:\\Windows\\Fenestra"));
            Assert.That(logger.GetLoggerInstance, Is.EqualTo("GetLoggerInstance"));
            Assert.That(logger.GetDirectoryForDependencyByLoggerName
            ("CustomLogger"), Is.EqualTo("C:\\Windows\\Temp"));
        }
开发者ID:incjonya,项目名称:demos,代码行数:16,代码来源:TestMockRepository.cs

示例3: Test_Initialize_Multiple_Stubs_Using_Repository_Of_Method

        public void Test_Initialize_Multiple_Stubs_Using_Repository_Of_Method()
        {
            // There is another way to initialize multiple stubs inside one
            // expression using LINQ-style syntax (using moq functional specification)
            // using MockRepository class

            // Arrange
            var repository = new MockRepository(MockBehavior.Default);
            ILoggerDependency logger = repository.Of<ILoggerDependency>()
                .Where(ld => ld.DefaultLogger == "DefaultLogger")
                .Where(ld => ld.GetCurrentDirectory() == "D:\\Temp")
                .Where(ld => ld.GetDirectoryByLoggerName(It.IsAny<string>()) == "C:\\Temp")
                .First();

            // Assert
            Assert.That(logger.GetCurrentDirectory(), Is.EqualTo("D:\\Temp"));
            Assert.That(logger.DefaultLogger, Is.EqualTo("DefaultLogger"));
            Assert.That(logger.GetDirectoryByLoggerName("CustomLogger"), Is.EqualTo("C:\\Temp"));
        }
开发者ID:SergeyTeplyakov,项目名称:Moq.Samples,代码行数:19,代码来源:MockRepositories.cs


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