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


C# MockRepository.Playback方法代码示例

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


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

示例1: MultiThreadedReplay

        public void MultiThreadedReplay()
        {
            var mocks = new MockRepository();
            var service = mocks.StrictMock<IService>();
            using (mocks.Record())
            {
                for (int i = 0; i < 100; i++)
                {
                    int i1 = i;

                    Expect.Call(() => service.Do("message" + i1));
                }
            }
            using (mocks.Playback())
            {
                int counter = 0;
                for (int i = 0; i < 100; i++)
                {
                    var i1 = i;
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        service.Do("message" + i1);
                        Interlocked.Increment(ref counter);
                    });
                }
                while (counter != 100)
                    Thread.Sleep(100);
            }
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:29,代码来源:FieldProblem_Naraga.cs

示例2: WillMerge_UnorderedRecorder_WhenRecorderHasSingleRecorderInside

        public void WillMerge_UnorderedRecorder_WhenRecorderHasSingleRecorderInside()
        {
            MockRepository mocks = new MockRepository();
            ICustomer customer = mocks.StrictMock<ICustomer>();

            CustomerMapper mapper = new CustomerMapper();

            using (mocks.Record())
            using (mocks.Ordered())
            {
                Expect.Call(customer.Id).Return(0);

                customer.IsPreferred = true;
            }

            ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(() =>
            {
                using (mocks.Playback())
                {
                    mapper.MarkCustomerAsPreferred(customer);
                }
            });

            Assert.Equal("Unordered method call! The expected call is: 'Ordered: { ICustomer.get_Id(); }' but was: 'ICustomer.set_IsPreferred(True);'", ex.Message);
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:25,代码来源:FieldProblem_Shane.cs

示例3: Ayende_View_On_Mocking

        public void Ayende_View_On_Mocking()
        {
            MockRepository mocks = new MockRepository();
            ISomeSystem mockSomeSystem = mocks.StrictMock<ISomeSystem>();

            using (mocks.Record())
            {
                Expect.Call(mockSomeSystem.GetFooFor<ExpectedBar>("foo"))
                    .Return(new List<ExpectedBar>());
            }

            ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
                () =>
                {
                    using (mocks.Playback())
                    {
                        ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);
                        cut.DoStuffWithExpectedBar("foo");
                    }
                }
                );

            Assert.Equal(@"ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.UnexpectedBar>(""foo""); Expected #1, Actual #1.
            ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.ExpectedBar>(""foo""); Expected #1, Actual #0.", ex.Message);
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:25,代码来源:FieldProblem_Rob.cs

示例4: NaturalSyntaxForCallingMethods

        public void NaturalSyntaxForCallingMethods()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();
            using (mocks.Record())
            {
                Expect.Call(demo.VoidNoArgs);
            }

            using (mocks.Playback())
            {
                demo.VoidNoArgs();
            }
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:14,代码来源:DotNet35Tests.cs

示例5: PlaybackThrowsOtherExceptionDoesntReport

 public void PlaybackThrowsOtherExceptionDoesntReport()
 {
     MockRepository mockRepository;
     mockRepository = new MockRepository();
     IFoo mockedFoo = mockRepository.StrictMock<IFoo>();
     using (mockRepository.Record())
     {
         Expect.Call(mockedFoo.Bar()).Return(42);
     }
     using (mockRepository.Playback())
     {
         throw new ArgumentException();
     }
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:14,代码来源:RecordPlaybackTests.cs

示例6: NaturalSyntaxForCallingMethods_WithArguments

        public void NaturalSyntaxForCallingMethods_WithArguments()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();
            using (mocks.Record())
            {
                Expect.Call( () => demo.VoidStringArg("blah") );
            }

            using (mocks.Playback())
            {
                demo.VoidStringArg("blah");
            }
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:14,代码来源:DotNet35Tests.cs

示例7: CanCallMethodWithParameters_WithoutSpecifyingParameters_WillAcceptAnyParameter

        public void CanCallMethodWithParameters_WithoutSpecifyingParameters_WillAcceptAnyParameter()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();
            using (mocks.Record())
            {
                Expect.Call(() => demo.VoidStringArg("blah")).IgnoreArguments();
            }

            using (mocks.Playback())
            {
                demo.VoidStringArg("asd");
            }
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:14,代码来源:DotNet35Tests.cs

示例8: CanRecordPlayback

 public void CanRecordPlayback()
 {
     MockRepository mockRepository;
     mockRepository = new MockRepository();
     IFoo mockedFoo = mockRepository.StrictMock<IFoo>();
     using (mockRepository.Record())
     {
         Expect.Call(mockedFoo.Bar()).Return(42);
     }
     using (mockRepository.Playback())
     {
         Fooz fooz = new Fooz(mockedFoo);
         fooz.Barz();
     }
 }
开发者ID:shiqinwen,项目名称:rhino-mocks,代码行数:15,代码来源:RecordPlaybackTests.cs

示例9: CanSetExpectationOnReadWritePropertyUsingRecordPlaybackSyntax

        public void CanSetExpectationOnReadWritePropertyUsingRecordPlaybackSyntax()
        {
            var mocks = new MockRepository();
            var demo = mocks.DynamicMock<IDemo>();

            using (mocks.Record())
            {
                demo.Expect(x => x.Prop).SetPropertyWithArgument("Eduardo");
            }

            using (mocks.Playback())
            {
                demo.Prop = "Eduardo";
            }
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:15,代码来源:FieldProblem_Eduardo.cs

示例10: Ayende_View_On_Mocking

        public void Ayende_View_On_Mocking()
        {
            MockRepository mocks = new MockRepository();
            ISomeSystem mockSomeSystem = mocks.StrictMock<ISomeSystem>();

            using (mocks.Record())
            {
                Expect.Call(mockSomeSystem.GetFooFor<ExpectedBar>("foo"))
                    .Return(new List<ExpectedBar>());
            }

            using (mocks.Playback())
            {
                ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);
                cut.DoStuffWithExpectedBar("foo");
            }
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:17,代码来源:FieldProblem_Rob.cs

示例11: Setter_Expectation_Not_Fullfilled

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

            IBar bar = mocks.StrictMock<IBar>();

            using (mocks.Record())
            {
                Expect.Call(bar.Foo).SetPropertyAndIgnoreArgument();
            }

            using (mocks.Playback())
            {
            }

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

示例12: CorrectResultForExpectedWhenUsingTimesWithRange

 public void CorrectResultForExpectedWhenUsingTimesWithRange()
 {
     MockRepository mocks = new MockRepository();
     IView view = mocks.StrictMock<IView>();
     using (mocks.Record())
     {
         view.RedrawDisplay(null);
         LastCall.Repeat.Times(3,4).IgnoreArguments();
     }
     using(mocks.Playback())
     {
         for (int i = 0; i < 5; i++)
         {
             view.RedrawDisplay("blah");
         }
     }
 }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:17,代码来源:FieldProblem_Robert.cs

示例13: IsMatching

 public void IsMatching()
 {
     MockRepository mocks = new MockRepository();
     IView view = mocks.StrictMock<IView>();
     using (mocks.Record())
     {
         view.Foo = null;
         Predicate<int> alwaysReturnsTrue = delegate(int input)
         {
             return true;
         };
         LastCall.Constraints(Is.Matching(alwaysReturnsTrue));
     }
     using (mocks.Playback())
     {
         view.Foo = 1;
     }
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:18,代码来源:FieldProblem_JudahG.cs

示例14: Setter_Expectation_Not_Fullfilled

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

            IBar bar = mocks.StrictMock<IBar>();

            using (mocks.Record())
            {
                Expect.Call(bar.Foo).SetPropertyAndIgnoreArgument();
            }

            Assert.Throws<ExpectationViolationException>("IBar.set_Foo(any); Expected #1, Actual #0.", () =>
            {
                using (mocks.Playback())
                {
                }
            });
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:18,代码来源:PropertySetterFixture.cs

示例15: TestOutMethod

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

            ITest mockProxy = mocks.StrictMock<ITest>();

            int intTest = 0;

            using (mocks.Record())
            {
                Expect.Call(delegate { mockProxy.Addnumber(out intTest);  }).OutRef(4);
            }
            using(mocks.Playback())
            {
                mockProxy.Addnumber(out intTest);
                Assert.Equal(4, intTest);
            }
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:18,代码来源:FieldProblem_Mithresh.cs


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