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


C# MockRepository.ReplayAll方法代码示例

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


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

示例1: Can_mix_assert_was_call_with_verify_all

        public void Can_mix_assert_was_call_with_verify_all()
        {
            MockRepository mocks = new MockRepository();
            var errorHandler = mocks.DynamicMock<IErrorHandler>();
            mocks.ReplayAll();

            var ex = new Exception("Take this");
            errorHandler.HandleError(ex);

            errorHandler.AssertWasCalled(eh => eh.HandleError(ex));

            mocks.ReplayAll();
            mocks.VerifyAll(); // Can I still keep this somehow?
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:14,代码来源:FieldProblem_Libardo.cs

示例2: 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

示例3: WillRememberExceptionInsideOrderRecorderEvenIfInsideCatchBlock

        public void WillRememberExceptionInsideOrderRecorderEvenIfInsideCatchBlock()
        {
            MockRepository mockRepository = new MockRepository();
            IInterfaceWithThreeMethods interfaceWithThreeMethods = mockRepository.StrictMock<IInterfaceWithThreeMethods>();

            using (mockRepository.Ordered())
            {
                interfaceWithThreeMethods.A();
                interfaceWithThreeMethods.C();
            }

            mockRepository.ReplayAll();

            interfaceWithThreeMethods.A();
            try
            {
                interfaceWithThreeMethods.B();
            }
            catch { /* valid for code under test to catch all */ }
            interfaceWithThreeMethods.C();

            string expectedMessage="Unordered method call! The expected call is: 'Ordered: { IInterfaceWithThreeMethods.C(); }' but was: 'IInterfaceWithThreeMethods.B();'";
            ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
                () => mockRepository.VerifyAll());
            Assert.Equal(expectedMessage, ex.Message);
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:26,代码来源:FieldProblem_Sam.cs

示例4: ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct

        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            MockRepository mocks = new MockRepository();
            ISomeService m_SomeServiceMock = mocks.StrictMock<ISomeService>();
            SomeClient sut = new SomeClient(m_SomeServiceMock);

            using (mocks.Ordered())
            {
                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething<string>(null, null);
                });
                LastCall.IgnoreArguments();

                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething<DateTime>(null, default(DateTime));  // can't use null here, because it's a value type!
                });
                LastCall.IgnoreArguments();

            }
            mocks.ReplayAll();

            // test
            sut.DoSomething();

            // verification
            mocks.VerifyAll();

            // cleanup
            m_SomeServiceMock = null;
            sut = null;
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:34,代码来源:FieldProblem_Stephan.cs

示例5: Test_View_Events_WiredUp

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

            IView view = mocks.StrictMock<IView>();

            // expect that the model is set on the view
            // NOTE: if I move this Expect.Call above
            // the above Expect.Call, Rhino mocks blows up on with an
            // "This method has already been set to ArgsEqualExpectation."
            // not sure why. Its a side issue.
            Expect.Call(view.Model = Arg<Model>.Is.NotNull);

            // expect the event ClickButton to be wired up
            IEventRaiser clickButtonEvent =
                    Expect.Call(delegate
                    {
                        view.ClickButton += null;
                    }).IgnoreArguments().GetEventRaiser();

            // Q: How do i set an expectation that checks that the controller
            // correctly updates the model in the event handler.
            // i.e. above we know that the controller executes
            // _model.UserName = "Keith here :)"
            // but how can I verify it?
            // The following wont work, because Model is null:
            // Expect.Call(view.Model.UserName = Arg<String>.Is.Anything);

            mocks.ReplayAll();

            Controller controller = new Controller(view);
            clickButtonEvent.Raise(null, null);

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

示例6: TestChar

 public void TestChar()
 {
     MockRepository mocks = new MockRepository();
     IProvider mockProvider = (IProvider)mocks.StrictMock(typeof(IProvider));
     SetupResult.For(mockProvider.GetChar()).Return('X');
     mocks.ReplayAll();
     Assert.Equal('X', mockProvider.GetChar()); // actual is a random char
 }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:8,代码来源:FieldProblem_Michael.cs

示例7: TestInt32

 public void TestInt32()
 {
     MockRepository mocks = new MockRepository();
     IProvider mockProvider = (IProvider)mocks.StrictMock(typeof(IProvider));
     SetupResult.For(mockProvider.GetInt32()).Return(100);
     mocks.ReplayAll();
     Assert.Equal(100, mockProvider.GetInt32()); // actual is 100
 }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:8,代码来源:FieldProblem_Michael.cs

示例8: Can_do_nested_virtual_calls_when_not_called

        public void Can_do_nested_virtual_calls_when_not_called()
        {
            var mocks = new MockRepository();
            var subject = mocks.PartialMock<SUT>();
            mocks.ReplayAll();

            subject.AssertWasCalled(it => it.NestedVirtualMethod());
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:8,代码来源:FieldProblem_Mike.cs

示例9: MockAClassWithFinalizer

 public void MockAClassWithFinalizer()
 {
     MockRepository mocks = new MockRepository();
     ClassWithFinalizer withFinalizer = (ClassWithFinalizer) mocks.StrictMock(typeof (ClassWithFinalizer));
     mocks.ReplayAll();
     mocks.VerifyAll(); //move it to verify state
     withFinalizer = null; // abandon the variable, will make it avialable for GC.
     GC.WaitForPendingFinalizers();
 }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:9,代码来源:FieldProblem_Eric.cs

示例10: MockClass

 public void MockClass()
 {
     MockRepository mocks = new MockRepository();
     RemotableDemoClass demo = (RemotableDemoClass)mocks.StrictMock(typeof(RemotableDemoClass));
     Expect.Call(demo.Two()).Return(44);
     mocks.ReplayAll();
     Assert.Equal(44, contextSwitcher.DoStuff(demo));
     mocks.VerifyAll();
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:9,代码来源:ContextSwitchTests.cs

示例11: Test

 public void Test()
 {
     MockRepository mocks = new MockRepository();
     SimpleOperations myMock = mocks.StrictMock<SimpleOperations>();
     Expect.Call(myMock.AddTwoValues(1, 2)).Return(3);
     mocks.ReplayAll();
     Assert.Equal(3, myMock.AddTwoValues(1, 2));
     mocks.VerifyAll();
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:9,代码来源:FieldProblem_Sam.cs

示例12: Can_do_nested_virtual_calls_when_not_called

        public void Can_do_nested_virtual_calls_when_not_called()
        {
            var mocks = new MockRepository();
            var subject = mocks.PartialMock<SUT>();
            mocks.ReplayAll();

            var ex = Assert.Throws<ExpectationViolationException>(() => subject.AssertWasCalled(it => it.NestedVirtualMethod()));
            Assert.Equal("SUT.NestedVirtualMethod(); Expected #1, Actual #0.", ex.Message);
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:9,代码来源:FieldProblem_Mike.cs

示例13: PropertiesWillBehaveLikeProperties

        public void PropertiesWillBehaveLikeProperties()
        {
            MockRepository mocks = new MockRepository();
            TestObject testObject = mocks.Stub<TestObject>();

            mocks.ReplayAll();

            Assert.Equal(0, testObject.IntProperty);
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:9,代码来源:FieldProblem_Christian.cs

示例14: SetUp

        public void SetUp()
        {
            _mocks = new MockRepository();

            _mockBase = _mocks.Stub<IBase>();
            _mockChild = _mocks.Stub<IChild>();

            _mocks.ReplayAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:9,代码来源:FieldProblem_Nolan.cs

示例15: CanMockInternalInterface

 public void CanMockInternalInterface()
 {
     MockRepository mocks = new MockRepository();
     IInternal mock = mocks.StrictMock<IInternal>();
     mock.Foo();
     mocks.ReplayAll();
     mock.Foo();
     mocks.VerifyAll();
 }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:9,代码来源:FieldProblem_Rabashani.cs


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