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