本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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();
}
示例5: MockWebUIPageClass
public void MockWebUIPageClass()
{
MockRepository mocks = new MockRepository();
Page page = (Page)mocks.StrictMock(typeof(Page));
page.Validate();
mocks.ReplayAll();
page.Validate();
mocks.VerifyAll();
}
示例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();
}
示例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();
}
示例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();
}
示例9: CanMockInternalInterface
public void CanMockInternalInterface()
{
MockRepository mocks = new MockRepository();
IInternal mock = mocks.StrictMock<IInternal>();
mock.Foo();
mocks.ReplayAll();
mock.Foo();
mocks.VerifyAll();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}