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


C# MockRepository.Unordered方法代码示例

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


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

示例1: CanUseSetupResultAndIgnoreArguments_WhenUsingUnorderedBlock

        public void CanUseSetupResultAndIgnoreArguments_WhenUsingUnorderedBlock()
        {
            MockRepository mocks = new MockRepository();
            IFetcher fetcher = mocks.DynamicMock<IFetcher>();

            using (mocks.Unordered())
            {
                SetupResult.For(fetcher.GetUsersWithCriteriaLike(null)).IgnoreArguments().Return(
                    new Student[] {new Student(), new Student()});
            }

            mocks.ReplayAll();

            Assert.Equal(2, fetcher.GetUsersWithCriteriaLike("foo").Length);
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:15,代码来源:SetupResultAndIgnoreArguments.cs

示例2: NestedInorderedAndAtLeastOnce

        public void NestedInorderedAndAtLeastOnce()
        {
            MockRepository mocks = new MockRepository();
            IMyObject myObject = mocks.StrictMock(typeof(IMyObject)) as IMyObject;

            using (mocks.Ordered())
            {
                using (mocks.Unordered()) // <-- Works only if ordered
                {
                    Expect.Call(myObject.SomeProperty).Return(null).Repeat.AtLeastOnce();
                }
                myObject.DoSomething();
            }

            mocks.ReplayAll();

            Assert.IsNull(myObject.SomeProperty);
            Assert.IsNull(myObject.SomeProperty);
            Assert.IsNull(myObject.SomeProperty);
            myObject.DoSomething();
            mocks.VerifyAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:22,代码来源:FieldProblem_Entropy.cs

示例3: UnorderedAndAtLeastOnce_CallingAnExtraMethod

        public void UnorderedAndAtLeastOnce_CallingAnExtraMethod()
        {
            MockRepository mocks = new MockRepository();
            IMyObject myObject = mocks.StrictMock(typeof(IMyObject)) as IMyObject;

            using (mocks.Unordered())
            {
                Expect.Call(myObject.SomeProperty).Return(null).Repeat.AtLeastOnce();
            }
            myObject.DoSomethingElse();

            mocks.ReplayAll();

            Assert.IsNull(myObject.SomeProperty);
            Assert.IsNull(myObject.SomeProperty);
            Assert.IsNull(myObject.SomeProperty);
            myObject.DoSomething();

            mocks.VerifyAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:20,代码来源:FieldProblem_Entropy.cs

示例4: UnorderedAndAtLeastOnce_CallingAnExtraMethod

        public void UnorderedAndAtLeastOnce_CallingAnExtraMethod()
        {
            MockRepository mocks = new MockRepository();
            IMyObject myObject = mocks.StrictMock(typeof(IMyObject)) as IMyObject;

            using (mocks.Unordered())
            {
                Expect.Call(myObject.SomeProperty).Return(null).Repeat.AtLeastOnce();
            }
            myObject.DoSomethingElse();

            mocks.ReplayAll();

            Assert.Null(myObject.SomeProperty);
            Assert.Null(myObject.SomeProperty);
            Assert.Null(myObject.SomeProperty);

            Assert.Throws<ExpectationViolationException>(
                @"IMyObject.DoSomething(); Expected #0, Actual #1.",
                () => myObject.DoSomething());
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:21,代码来源:FieldProblem_Entropy.cs

示例5: ConfigureOrderedTimesMin0WithNestedUnordered

 private static void ConfigureOrderedTimesMin0WithNestedUnordered(MockRepository mocks, I1 mockObject)
 {
     using (mocks.Ordered())
     {
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
         using (mocks.Unordered())
         {
             mockObject.B();
             mockObject.C();
         }
         mockObject.A();
         LastCall.Repeat.Times(0, 1);
     }
 }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:15,代码来源:OrderTest.cs

示例6: SetupResultWithNestedOrdering

        public void SetupResultWithNestedOrdering()
        {
            MockRepository mocks = new MockRepository();
            ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
                femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));

            SetupResult.On(maleBird).Call(maleBird.Sing()).Return("");
            using (mocks.Ordered())
            {
                using (mocks.Unordered())
                {
                    maleBird.Eat("seeds", 250);
                    femaleBird.Eat("seeds", 250);
                }

                using (mocks.Unordered())
                {
                    maleBird.Mate(femaleBird);
                    femaleBird.Mate(maleBird);
                }
            }
            mocks.ReplayAll();

            maleBird.Sing();
            femaleBird.Eat("seeds", 250);
            maleBird.Sing();
            maleBird.Eat("seeds", 250);

            maleBird.Sing();
            femaleBird.Mate(maleBird);
            maleBird.Sing();
            maleBird.Mate(femaleBird);
            maleBird.Sing();
            mocks.VerifyAll();
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:35,代码来源:IntegrationTests.cs

示例7: OrderedExecutionOfUnorderedSequence

        public void OrderedExecutionOfUnorderedSequence()
        {
            MockRepository mocks = new MockRepository();
            ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
                femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));

            using (mocks.Ordered())
            {
                using (mocks.Unordered())
                {
                    maleBird.Eat("seeds", 250);
                    femaleBird.Eat("seeds", 250);
                }

                using (mocks.Unordered())
                {
                    maleBird.Mate(femaleBird);
                    femaleBird.Mate(maleBird);
                }
            }
            mocks.ReplayAll();

            femaleBird.Eat("seeds", 250);
            maleBird.Eat("seeds", 250);

            femaleBird.Mate(maleBird);
            maleBird.Mate(femaleBird);

            mocks.VerifyAll();
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:30,代码来源:IntegrationTests.cs

示例8: ExampleUsingCallbacks

        public void ExampleUsingCallbacks()
        {
            MockRepository mocks = new MockRepository();

            ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
                femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));

            using (mocks.Ordered())
            {
                using (mocks.Unordered())
                {
                    maleBird.MoveToCage(null);
                    LastCall.On(maleBird).Callback(new CageDelegate(IsSameCage));
                    femaleBird.MoveToCage(null);
                    LastCall.On(femaleBird).Callback(new CageDelegate(IsSameCage));
                }
                maleBird.Eat("seeds", 250);
                femaleBird.Eat("seeds", 250);
                using (mocks.Unordered())
                {
                    maleBird.Mate(femaleBird);
                    femaleBird.Mate(maleBird);
                }
            }
            mocks.ReplayAll();

            BirdVeterinary vet = new BirdVeterinary();
            vet.Mate(maleBird, femaleBird);
            mocks.VerifyAll();
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:30,代码来源:IntegrationTests.cs

示例9: SubmitDataToDB

        public void SubmitDataToDB()
        {
            //Setup a mock view and ISumbition
            MockRepository mocks = new MockRepository();
            IView myMockView = (IView) mocks.DynamicMock(typeof (IView));
            ISumbition myMockSubmition = (ISumbition) mocks.DynamicMock(typeof (ISumbition));

            //Record expectations
            SetupResult.For(myMockView.UserID).Return(3105596L);
            SetupResult.For(myMockView.Name).Return("Someone");
            SetupResult.For(myMockView.Address).Return("Somewhere");

            using (mocks.Ordered())
            {
                using (mocks.Unordered())
                {
                    myMockSubmition.Name = "Someone";
                    myMockSubmition.Address = "Somewhere";
                    myMockSubmition.UserID = 3105596L;
                }
                myMockSubmition.Save();
            }

            //setup the present
            mocks.ReplayAll();

            Presneter myPresenter = new Presneter(myMockView, myMockSubmition);
            myPresenter.Sumbit();

            mocks.VerifyAll();
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:31,代码来源:FieldProblem_AviOrdering.cs


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