當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。