本文整理汇总了C#中MockRepository.Replay方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Replay方法的具体用法?C# MockRepository.Replay怎么用?C# MockRepository.Replay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockRepository
的用法示例。
在下文中一共展示了MockRepository.Replay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanMoveToRecordAndThenReplay
public void CanMoveToRecordAndThenReplay()
{
MockRepository mocks = new MockRepository();
IDemo demo = (IDemo)mocks.StrictMock(typeof(IDemo));
Expect.Call(demo.Prop).Return("ayende");
mocks.Replay(demo);
Assert.AreEqual("ayende", demo.Prop);
mocks.BackToRecord(demo);
Expect.Call(demo.Prop).Return("rahien");
mocks.Replay(demo);
Assert.AreEqual("rahien", demo.Prop);
mocks.VerifyAll();
}
示例2: UsingBackToRecordWithSetUpResult
public void UsingBackToRecordWithSetUpResult()
{
MockRepository mocks = new MockRepository();
IDemo demo = (IDemo) mocks.StrictMock(typeof(IDemo));
SetupResult.For(demo.Prop).Return("Here is 1 sample greeting");
mocks.Replay(demo);
Assert.Equal("Here is 1 sample greeting",demo.Prop);
mocks.BackToRecord(demo);
SetupResult.For(demo.Prop).Return("Here is another sample greeting");
mocks.Replay(demo);
Assert.Equal("Here is another sample greeting", demo.Prop);
mocks.VerifyAll();
}
示例3: 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();
}
示例4: MockClassWithEquals
public void MockClassWithEquals()
{
MockRepository mocks = new MockRepository();
ClassThatOverrideEquals c = (ClassThatOverrideEquals)mocks.StrictMock(typeof(ClassThatOverrideEquals));
c.Equals(c);
LastCall.Return(false);
mocks.Replay(c);
Assert.IsFalse(c.Equals(c));
mocks.Verify(c);
}
示例5: CanUseNonRecordReplayModel_Expect_OnVoidMethod_WhenMethodNotcall_WillFailTest
public void CanUseNonRecordReplayModel_Expect_OnVoidMethod_WhenMethodNotcall_WillFailTest()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
demo.Expect(x => x.DoSomethingElse());
mocks.Replay(demo);
mocks.VerifyAll();
}
示例6: CanOnlyPassSingleExpectationToVerify
public void CanOnlyPassSingleExpectationToVerify()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
mocks.Replay(demo);
demo.AssertWasCalled(x =>
{
x.DoSomethingElse();
x.DoSomethingElse();
});
}
示例7: CanUseNonRecordReplayModel_Expect
public void CanUseNonRecordReplayModel_Expect()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
demo.Expect(x => x.DoSomething()).Return(1).Repeat.Once();
mocks.Replay(demo);
Assert.AreEqual(1, demo.DoSomething());
demo.Expect(x => x.DoSomething()).Return(15).Repeat.Once();
Assert.AreEqual(15, demo.DoSomething());
mocks.VerifyAll();
}
示例8: WillRaiseErrorIfNoExpectationWasSetup
public void WillRaiseErrorIfNoExpectationWasSetup()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
mocks.Replay(demo);
demo.AssertWasCalled(x => { });
}
示例9: WillRaiseErrorIfNoExpectationWasSetup
public void WillRaiseErrorIfNoExpectationWasSetup()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
mocks.Replay(demo);
Assert.Throws<InvalidOperationException>(
"No expectations were setup to be verified, ensure that the method call in the action is a virtual (C#) / overridable (VB.Net) method call",
() => demo.AssertWasCalled(x => { }));
}
示例10: CanUseNonRecordReplayModel_Stub_OnVoidMethod
public void CanUseNonRecordReplayModel_Stub_OnVoidMethod()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
demo.Stub(x => x.DoSomethingElse()).Throw(new InvalidOperationException("foo"));
mocks.Replay(demo);
try
{
demo.DoSomethingElse();
Assert.Fail("Should throw");
}
catch (InvalidOperationException e)
{
Assert.AreEqual("foo", e.Message);
}
}
示例11: TypeShouldBeInferredFromMockNotReference
public void TypeShouldBeInferredFromMockNotReference()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<Foo54>(0);
demo.Stub(x => x.DoSomethingElse());
mocks.Replay(demo);
demo.DoSomethingElse();
demo.AssertWasCalled(x => x.DoSomethingElse());
}
示例12: AssertShouldWorkWithoutStub
public void AssertShouldWorkWithoutStub()
{
var mocks = new MockRepository();
var demo = mocks.DynamicMock<IFoo54>();
mocks.Replay(demo);
demo.DoSomethingElse();
demo.AssertWasCalled(x => x.DoSomethingElse());
}
示例13: CanAssertNotCalledOnPropertyAccess
public void CanAssertNotCalledOnPropertyAccess()
{
MockRepository mocks = new MockRepository();
IFoo54 demo = mocks.DynamicMock<IFoo54>();
mocks.Replay(demo);
demo.DoSomething();
demo.AssertWasNotCalled(x => x.FooBar);
}
示例14: CallingReplayOnNonMockThrows
public void CallingReplayOnNonMockThrows()
{
MockRepository mocks = new MockRepository();
var ex = Assert.Throws<ObjectNotMockFromThisRepositoryException>(() => mocks.Replay(new object()));
Assert.Equal("The object is not a mock object that belong to this repository.", ex.Message);
}
示例15: WillGetSameInstanceOfRecursedMockInReplayMode
public void WillGetSameInstanceOfRecursedMockInReplayMode()
{
RhinoMocks.Logger = new TraceWriterExpectationLogger(true, true, true);
MockRepository mocks = new MockRepository();
var mock = mocks.DynamicMock<IMyService>();
mocks.Replay(mock);
IIdentity i1 = mock.Identity;
IIdentity i2 = mock.Identity;
Assert.Same(i1, i2);
Assert.NotNull(i1);
}