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


C# MockRepository.Replay方法代码示例

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


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

示例1: CanMoveToRecordAndThenReplay

 public void CanMoveToRecordAndThenReplay()
 {
     MockRepository mocks = new MockRepository();
     IDemo demo = (IDemo)mocks.StrictMock(typeof(IDemo));
     Expect.Call(demo.Prop).Return("ayende");
     mocks.Replay(demo);
     Assert.AreEqual("ayende", demo.Prop);
     mocks.BackToRecord(demo);
     Expect.Call(demo.Prop).Return("rahien");
     mocks.Replay(demo);
     Assert.AreEqual("rahien", demo.Prop);
     mocks.VerifyAll();
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:13,代码来源:BackToRecord.cs

示例2: UsingBackToRecordWithSetUpResult

 public void UsingBackToRecordWithSetUpResult()
 {
     MockRepository mocks = new MockRepository();
     IDemo demo = (IDemo) mocks.StrictMock(typeof(IDemo));
     SetupResult.For(demo.Prop).Return("Here is 1 sample greeting");
     mocks.Replay(demo);
     Assert.Equal("Here is 1 sample greeting",demo.Prop);
     mocks.BackToRecord(demo);
     SetupResult.For(demo.Prop).Return("Here is another sample greeting");
     mocks.Replay(demo);
     Assert.Equal("Here is another sample greeting", demo.Prop);
     mocks.VerifyAll();
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:13,代码来源:FieldProblem_BackToMockWithRepeatableMethods.cs

示例3: CanUseExpectSyntax_OnMockWithOrderedExpectations

        public void CanUseExpectSyntax_OnMockWithOrderedExpectations(bool shouldSwitchToReplyImmediately)
        {
            MockRepository mocks = new MockRepository();

            var foo54 = mocks.StrictMock<IFoo54>();
            if (shouldSwitchToReplyImmediately)
                mocks.ReplayAll();

            using (mocks.Ordered())
            {
                foo54
                    .Expect(x => x.DoSomething())
                    .Return(0);

                foo54
                    .Expect(x => x.DoSomethingElse());
            }

            if (!shouldSwitchToReplyImmediately)
                mocks.Replay(foo54);

            foo54.DoSomething();
            foo54.DoSomethingElse();

            foo54.VerifyAllExpectations();
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:26,代码来源:FieldProblem_Jodran.cs

示例4: MockClassWithEquals

 public void MockClassWithEquals()
 {
     MockRepository mocks = new MockRepository();
     ClassThatOverrideEquals c = (ClassThatOverrideEquals)mocks.StrictMock(typeof(ClassThatOverrideEquals));
     c.Equals(c);
     LastCall.Return(false);
     mocks.Replay(c);
     Assert.IsFalse(c.Equals(c));
     mocks.Verify(c);
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:10,代码来源:FieldProblem_Daniel.cs

示例5: CanUseNonRecordReplayModel_Expect_OnVoidMethod_WhenMethodNotcall_WillFailTest

        public void CanUseNonRecordReplayModel_Expect_OnVoidMethod_WhenMethodNotcall_WillFailTest()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();

            demo.Expect(x => x.DoSomethingElse());
            mocks.Replay(demo);

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

示例6: CanOnlyPassSingleExpectationToVerify

        public void CanOnlyPassSingleExpectationToVerify()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();
            mocks.Replay(demo);

            demo.AssertWasCalled(x =>
                            {
                                x.DoSomethingElse();
                                x.DoSomethingElse();
                            });
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:12,代码来源:RecordingMocks.cs

示例7: CanUseNonRecordReplayModel_Expect

        public void CanUseNonRecordReplayModel_Expect()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();

            demo.Expect(x => x.DoSomething()).Return(1).Repeat.Once();
            mocks.Replay(demo);
            Assert.AreEqual(1, demo.DoSomething());
            demo.Expect(x => x.DoSomething()).Return(15).Repeat.Once();
            Assert.AreEqual(15, demo.DoSomething());

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

示例8: WillRaiseErrorIfNoExpectationWasSetup

        public void WillRaiseErrorIfNoExpectationWasSetup()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();
            mocks.Replay(demo);

            demo.AssertWasCalled(x => { });
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:8,代码来源:RecordingMocks.cs

示例9: WillRaiseErrorIfNoExpectationWasSetup

        public void WillRaiseErrorIfNoExpectationWasSetup()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();
            mocks.Replay(demo);

            Assert.Throws<InvalidOperationException>(
                "No expectations were setup to be verified, ensure that the method call in the action is a virtual (C#) / overridable (VB.Net) method call",
                () => demo.AssertWasCalled(x => { }));
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:10,代码来源:RecordingMocks.cs

示例10: CanUseNonRecordReplayModel_Stub_OnVoidMethod

        public void CanUseNonRecordReplayModel_Stub_OnVoidMethod()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();

            demo.Stub(x => x.DoSomethingElse()).Throw(new InvalidOperationException("foo"));
            mocks.Replay(demo);

            try
            {
                demo.DoSomethingElse();
                Assert.Fail("Should throw");
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual("foo", e.Message);
            }
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:18,代码来源:RecordingMocks.cs

示例11: TypeShouldBeInferredFromMockNotReference

        public void TypeShouldBeInferredFromMockNotReference()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<Foo54>(0);

            demo.Stub(x => x.DoSomethingElse());
            mocks.Replay(demo);

            demo.DoSomethingElse();

            demo.AssertWasCalled(x => x.DoSomethingElse());
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:12,代码来源:RecordingMocks.cs

示例12: AssertShouldWorkWithoutStub

        public void AssertShouldWorkWithoutStub()
        {
            var mocks = new MockRepository();
            var demo = mocks.DynamicMock<IFoo54>();
            mocks.Replay(demo);
            demo.DoSomethingElse();

            demo.AssertWasCalled(x => x.DoSomethingElse());
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:9,代码来源:RecordingMocks.cs

示例13: CanAssertNotCalledOnPropertyAccess

        public void CanAssertNotCalledOnPropertyAccess()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();
            mocks.Replay(demo);

            demo.DoSomething();

            demo.AssertWasNotCalled(x => x.FooBar);
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:10,代码来源:RecordingMocks.cs

示例14: CallingReplayOnNonMockThrows

 public void CallingReplayOnNonMockThrows()
 {
     MockRepository mocks = new MockRepository();
     var ex = Assert.Throws<ObjectNotMockFromThisRepositoryException>(() => mocks.Replay(new object()));
     Assert.Equal("The object is not a mock object that belong to this repository.", ex.Message);
 }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:6,代码来源:MockRepositoryTests.cs

示例15: WillGetSameInstanceOfRecursedMockInReplayMode

        public void WillGetSameInstanceOfRecursedMockInReplayMode()
        {
            RhinoMocks.Logger = new TraceWriterExpectationLogger(true, true, true);

            MockRepository mocks = new MockRepository();
            var mock = mocks.DynamicMock<IMyService>();
            mocks.Replay(mock);

            IIdentity i1 = mock.Identity;
            IIdentity i2 = mock.Identity;

            Assert.Same(i1, i2);
            Assert.NotNull(i1);
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:14,代码来源:RecursiveMocks.cs


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