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


C# MockRepository.OneOf方法代码示例

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


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

示例1: LocalBallancerConstructorTestNull1

        public void LocalBallancerConstructorTestNull1()
        {
            var moq = new MockRepository(MockBehavior.Default);

            var ballancer = new LocalBallancer<int>(null, moq.OneOf<IPerformanceManager>(),
                moq.OneOf<IRemoteMachinesManager>(), 1);
            Assert.IsNotNull(ballancer);
        }
开发者ID:wjch-krl,项目名称:Affrodite,代码行数:8,代码来源:LocalBallancerTest.cs

示例2: LocalBallancerConstructorTestNull3

        public void LocalBallancerConstructorTestNull3()
        {
            var moq = new MockRepository(MockBehavior.Default);

            var ballancer = new LocalBallancer<int>(moq.OneOf<IBallancerTask<int>>(), moq.OneOf<IPerformanceManager>(),
                null, 1);
            Assert.IsNotNull(ballancer);
        }
开发者ID:wjch-krl,项目名称:Affrodite,代码行数:8,代码来源:LocalBallancerTest.cs

示例3: StrartLoadBallancerTestNoConf

        public void StrartLoadBallancerTestNoConf()
        {
            var moq = new MockRepository(MockBehavior.Default);

            var config = new SimpleConfig(@"nonfile.xml");
            config.StrartLoadBallancer(moq.OneOf<IBallancerTask<int>>());
        }
开发者ID:wjch-krl,项目名称:Affrodite,代码行数:7,代码来源:SimpleConfigTest.cs

示例4: Test_Initialize_Multiple_Stubs_Using_Repository_OneOf_Method

        public void Test_Initialize_Multiple_Stubs_Using_Repository_OneOf_Method()
        {
            // MockRepository supports two ways for building subs.
            // Instead of calling "Of" method we can call OneOf and
            // use the same syntax as for creating stubs via Mock.Of

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

            // 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,代码行数:18,代码来源:MockRepositories.cs

示例5: LocalBallancerStartTest

        public void LocalBallancerStartTest()
        {
            var machineMgrMoq = new Mock<IRemoteMachinesManager>();
            var moq = new MockRepository(MockBehavior.Default);
            const int machCount = 7;
            machineMgrMoq.Setup(manager => manager.UnaviableHosts()).Returns(new[] { 2,5,6 });
            machineMgrMoq.Setup(m => m.Count).Returns(machCount);

            int ijk = 0;
            var recived = new List<int>();
            int tmp = 0;

            var ballancerTask = new BallancerDelagateTask<int?>(i =>
            {
                if (ijk != 100) return new int?[] {ijk++};
                return Enumerable.Empty<int?>();
            }, i =>
            {
                if (i != null) recived.Add(i.Value);
                else
                {
                    tmp++;
                    if (tmp > ijk)
                    lock (this)
                    {
                        Monitor.PulseAll(this);
                        return true;
                    }
                }
                return true;
            }, 1);

            var ballancer = new LocalBallancer<int?>(ballancerTask,
                moq.OneOf<IPerformanceManager>(),
                machineMgrMoq.Object, 1);
            var task = ballancer.StartAsync();

            lock (this)
            {
                Monitor.Wait(this);
                Assert.IsTrue(recived.Count > ijk / machCount, "{0}", recived.Count);
            }

            Assert.IsNotNull(ballancer);
            Assert.IsFalse(task.IsCanceled);
            Assert.IsFalse(task.IsFaulted);
            Assert.IsFalse(task.IsCanceled);
        }
开发者ID:wjch-krl,项目名称:Affrodite,代码行数:48,代码来源:LocalBallancerTest.cs


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