本文整理汇总了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());
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例6: SetUp
public void SetUp()
{
mocks = new MockRepository();
abs = (AbstractClass)mocks.PartialMock(typeof(AbstractClass));
}
示例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;
}
示例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);
}
示例9: MockingConcreteForm
public void MockingConcreteForm()
{
MockRepository mocks = new MockRepository();
Form frm = mocks.PartialMock<Form>();
Assert.NotNull(frm);
}
示例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();
}
示例11: PartialMockTests
public PartialMockTests()
{
mocks = new MockRepository();
abs = (AbstractClass)mocks.PartialMock(typeof(AbstractClass));
}