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


C# MockRepository.VerifyAll方法代码示例

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


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

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

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

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

 public void CanMockInternalClass()
 {
     MockRepository mocks = new MockRepository();
     Internal mock = mocks.StrictMock<Internal>();
     Expect.Call(mock.Bar()).Return("blah");
     mocks.ReplayAll();
     Assert.AreEqual("blah", mock.Bar());
     mocks.VerifyAll();
 }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:9,代码来源:FieldProblem_Rabashani.cs

示例5: MockWebUIPageClass

 public void MockWebUIPageClass()
 {
     MockRepository mocks = new MockRepository();
     Page page = (Page)mocks.StrictMock(typeof(Page));
     page.Validate();
     mocks.ReplayAll();
     page.Validate();
     mocks.VerifyAll();
 }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:9,代码来源:FieldProblem_David.cs

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

示例7: SettingExpectationOnIndexer

 public void SettingExpectationOnIndexer()
 {
     MockRepository mocks = new MockRepository();
     IndexerInterface indexer = (IndexerInterface) mocks.StrictMock(typeof (IndexerInterface));
     Expect.On(indexer).Call(indexer["1"]).Return("First");
     mocks.ReplayAll();
     Assert.Equal("First", indexer["1"]);
     mocks.VerifyAll();
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:9,代码来源:IndexerTests.cs

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

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

示例10: CanPartialMockInternalClass

 public void CanPartialMockInternalClass()
 {
     MockRepository mocks = new MockRepository();
     Internal mock = mocks.PartialMock<Internal>();
     Expect.Call(mock.Foo()).Return("blah");
     mocks.ReplayAll();
     Assert.Equal("blah", mock.Foo());
     Assert.Equal("abc", mock.Bar());
     mocks.VerifyAll();
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:10,代码来源:FieldProblem_Rabashani.cs

示例11: MockClassWithVirtualMethodCallFromConstructor

 public void MockClassWithVirtualMethodCallFromConstructor()
 {
     MockRepository mocks = new MockRepository();
     ClassWithVirtualMethodCallFromConstructor cwvmcfc = (ClassWithVirtualMethodCallFromConstructor)mocks.StrictMock(typeof(ClassWithVirtualMethodCallFromConstructor));
     Assert.NotNull(cwvmcfc);
     Expect.Call(cwvmcfc.ToString()).Return("Success");
     mocks.ReplayAll();
     Assert.Equal("Success", cwvmcfc.ToString());
     mocks.VerifyAll();
 }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:10,代码来源:FieldProblem_David.cs

示例12: CanSetExpectationsOnInterfaceWithGenericMethod

 public void CanSetExpectationsOnInterfaceWithGenericMethod()
 {
     MockRepository mocks = new MockRepository();
     IFactory factory = mocks.StrictMock<IFactory>();
     Expect.Call(factory.Create<string>()).Return("working?");
     mocks.ReplayAll();
     string result = factory.Create<string>();
     Assert.Equal("working?",result);
     mocks.VerifyAll();
 }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:10,代码来源:GenericMethods.cs

示例13: MockingRecordSet

 public void MockingRecordSet()
 {
     MockRepository mr = new MockRepository();
     Recordset mock = mr.StrictMock<ADODB.Recordset>();
     Assert.NotNull(mock);
     Expect.Call(mock.ActiveConnection).Return("test");
     mr.ReplayAll();
     Assert.Equal("test", mock.ActiveConnection);
     mr.VerifyAll();
 }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:10,代码来源:FieldProblem_dyowee.cs

示例14: TestMethod1

 public void TestMethod1()
 {
     ServiceDomain.Enter(new ServiceConfig());
     MockRepository mocks = new MockRepository();
     ISomething something = (ISomething)mocks.StrictMock(typeof(ISomething));
     mocks.ReplayAll();
     mocks.VerifyAll();
     ContextUtil.SetAbort();
     ServiceDomain.Leave();
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:10,代码来源:FieldProblem_Bruno.cs

示例15: CreateObjectUsingInterfaceInheritance

 public void CreateObjectUsingInterfaceInheritance()
 {
     MockRepository mocks = new MockRepository();
     ILocalizer localizer = (ILocalizer)mocks.StrictMock(typeof(ILocalizer));
     Assert.NotNull(localizer);
     typeof(ILocalizer).IsAssignableFrom(localizer.GetType());
     typeof(ICloneable).IsAssignableFrom(localizer.GetType());
     mocks.ReplayAll();
     mocks.VerifyAll();
 }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:10,代码来源:InterfaceInheritance.cs


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