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


C# MockRepository.PartialMock方法代码示例

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


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

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

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

示例3: CanPartialMockInternalClass

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

示例4: Virtual_protected_method_called_from_ctor_is_not_called_during_partial_mock_construction

        public void Virtual_protected_method_called_from_ctor_is_not_called_during_partial_mock_construction()
        {
            string mockedResult = "mocked result";

            MockRepository mockRepository = new MockRepository();
            ConcreteProtectedMethodCalledFromCtor concreteProtectedMethodCalledFromCtor = mockRepository.PartialMock<ConcreteProtectedMethodCalledFromCtor>();

            Expect.Call(concreteProtectedMethodCalledFromCtor.SimplyHereSoThereIsSomethingToMock()).Return(mockedResult);

            mockRepository.ReplayAll();

            string result = concreteProtectedMethodCalledFromCtor.SimplyHereSoThereIsSomethingToMock();

            mockRepository.VerifyAll();

            Assert.AreEqual(mockedResult, result);
            Assert.AreEqual(true, concreteProtectedMethodCalledFromCtor.WasAbstractMethodCalledFromCtor);
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:18,代码来源:FieldProblem_Kevin.cs

示例5: MockingPropertyUsingBaseKeyword

        public void MockingPropertyUsingBaseKeyword()
        {
            MockRepository mocks = new MockRepository();
            SubClass mock = mocks.PartialMock<SubClass>();

            Expect.Call(mock.SubProperty)
                .Return("Foo")
                .Repeat.Any();
            Expect.Call(mock.BaseProperty)
                .Return("Foo2")
                .Repeat.Any();

            mocks.ReplayAll();

            Assert.Equal("Foo", mock.SubProperty);
            Assert.Equal("Foo2", mock.BaseProperty);

            mocks.VerifyAll();
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:19,代码来源:FieldProblem_Andy.cs

示例6: SetUp

 public void SetUp()
 {
     mocks = new MockRepository();
     abs = (AbstractClass)mocks.PartialMock(typeof(AbstractClass));
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:5,代码来源:PartialMockTests.cs

示例7: CreateFakePageTypeUpdaterWithUpdatePageTypeMethodHelperStubs

 private PageTypeUpdater CreateFakePageTypeUpdaterWithUpdatePageTypeMethodHelperStubs()
 {
     MockRepository mocks = new MockRepository();
     PageTypeUpdater pageTypeUpdater = mocks.PartialMock<PageTypeUpdater>(
         PageTypeDefinitionLocatorFactory.Stub(), 
         new PageTypeFactory(),
         new PageTypeValueExtractor(),
         new PageTypeLocator(new PageTypeFactory()));
     PageTypeFactory pageTypeFactory = mocks.Stub<PageTypeFactory>();
     pageTypeFactory.Stub(factory => factory.Save(Arg<IPageType>.Is.Anything));
     pageTypeFactory.Replay();
     pageTypeUpdater.PageTypeFactory = pageTypeFactory;
     pageTypeUpdater.Stub(updater => updater.GetExistingPageType(Arg<PageTypeDefinition>.Is.Anything)).Return(new NativePageType());
     pageTypeUpdater.Stub(updater => updater.UpdateName(Arg<IPageType>.Is.Anything, Arg<PageTypeDefinition>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateFilename(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateSortOrder(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDescription(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateIsAvailable(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultArchivePageLink(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultChildOrderRule(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultPageName(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultPeerOrder(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultStartPublishOffset(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultStopPublishOffset(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateDefaultVisibleInMenu(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateFrame(Arg<IPageType>.Is.Anything, Arg<PageTypeAttribute>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.UpdateAvailablePageTypes(Arg<IPageType>.Is.Anything, Arg<Type[]>.Is.Anything));
     pageTypeUpdater.Stub(updater => updater.SerializeValues(Arg<IPageType>.Is.Anything)).Repeat.Once().Return(string.Empty);
     pageTypeUpdater.Stub(updater => updater.SerializeValues(Arg<IPageType>.Is.Anything)).Repeat.Once().Return("test");
     pageTypeUpdater.Replay();
     return pageTypeUpdater;
 }
开发者ID:andreasnico,项目名称:Page-Type-Builder,代码行数:32,代码来源:UpdatePageTypeMethodTests.cs

示例8: GivenTypeArray_WhenUpdateAvailablePageTypesCalled_SetsPageTypeAllowedPageTypes

        public void GivenTypeArray_WhenUpdateAvailablePageTypesCalled_SetsPageTypeAllowedPageTypes()
        {
            PageTypeDefinition definition = PageTypeUpdaterTestsUtility.CreateBasicPageTypeDefinition();
            definition.Attribute.AvailablePageTypes = new[] { typeof(object) };
            IPageType existingPageType = new NativePageType();
            MockRepository mocks = new MockRepository();
            List<PageTypeDefinition> definitions = new List<PageTypeDefinition>();
            PageTypeDefinition definitionToReturn = new PageTypeDefinition
            {
                Type = typeof(object),
                Attribute = new PageTypeAttribute()
            };
            definitions.Add(definitionToReturn);
            var pageTypeDefinitionLocator = PageTypeDefinitionLocatorFactory.Mock();
            pageTypeDefinitionLocator.Setup(locator => locator.GetPageTypeDefinitions()).Returns(definitions);
            PageTypeUpdater pageTypeUpdater = mocks.PartialMock<PageTypeUpdater>(
                pageTypeDefinitionLocator.Object, 
                new PageTypeFactory(),
                new PageTypeValueExtractor(),
                new PageTypeLocator(new PageTypeFactory()));
            IPageType allowedPageType = new NativePageType();
            allowedPageType.ID = 1;
            pageTypeUpdater.Stub(updater => updater.GetExistingPageType(definitionToReturn)).Return(allowedPageType);
            pageTypeUpdater.Replay();

            pageTypeUpdater.UpdateAvailablePageTypes(existingPageType, definition.Attribute.AvailablePageTypes);

            Assert.Equal<int[]>(new[] { 1 }, existingPageType.AllowedPageTypes);
        }
开发者ID:andreasnico,项目名称:Page-Type-Builder,代码行数:29,代码来源:UpdatePageTypeMethodTests.cs

示例9: MockingConcreteForm

 public void MockingConcreteForm()
 {
     MockRepository mocks = new MockRepository();
     Form frm = mocks.PartialMock<Form>();
     Assert.NotNull(frm);
 }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:6,代码来源:FieldProblem_Joe.cs

示例10: UsingPartialMocks

        public void UsingPartialMocks()
        {
            MockRepository mocks = new MockRepository();
            ProcessorBase proc = (ProcessorBase) mocks.PartialMock(typeof (ProcessorBase));
            Expect.Call(proc.Add(1)).Return(1);
            Expect.Call(proc.Add(1)).Return(2);

            mocks.ReplayAll();

            proc.Inc();
            Assert.AreEqual(1, proc.Register);
            proc.Inc();
            Assert.AreEqual(2, proc.Register);

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

示例11: PartialMockTests

 public PartialMockTests()
 {
     mocks = new MockRepository();
     abs = (AbstractClass)mocks.PartialMock(typeof(AbstractClass));
 }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:5,代码来源:PartialMockTests.cs


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