本文整理汇总了C#中MockRepository.BackToRecord方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.BackToRecord方法的具体用法?C# MockRepository.BackToRecord怎么用?C# MockRepository.BackToRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockRepository
的用法示例。
在下文中一共展示了MockRepository.BackToRecord方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanClearOnlyOriginalMethodCalls
public void CanClearOnlyOriginalMethodCalls()
{
MockRepository mocks = new MockRepository();
AbstractClass abstractClass = mocks.StrictMock<AbstractClass>();
Expect.Call(abstractClass.Add(0)).CallOriginalMethod(OriginalCallOptions.NoExpectation);
mocks.BackToRecord(abstractClass, BackToRecordOptions.OriginalMethodsToCall);
mocks.ReplayAll();
abstractClass.Add(5);
}
示例2: CanClearOnlyPropertyBehavior
public void CanClearOnlyPropertyBehavior()
{
MockRepository mocks = new MockRepository();
IDemo mock = mocks.StrictMock<IDemo>();
Expect.Call(mock.Prop).PropertyBehavior();
mocks.BackToRecord(mock,BackToRecordOptions.PropertyBehavior);
mocks.ReplayAll();
string prop = mock.Prop;
}
示例3: CanClearOnlyOriginalMethodCalls
public void CanClearOnlyOriginalMethodCalls()
{
MockRepository mocks = new MockRepository();
AbstractClass abstractClass = mocks.StrictMock<AbstractClass>();
Expect.Call(abstractClass.Add(0)).CallOriginalMethod(OriginalCallOptions.NoExpectation);
mocks.BackToRecord(abstractClass, BackToRecordOptions.OriginalMethodsToCall);
mocks.ReplayAll();
Assert.Throws<ExpectationViolationException>(
"AbstractClass.Add(5); Expected #0, Actual #1.",
() => abstractClass.Add(5));
}
示例4: 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();
}
示例5: 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();
}
示例6: CanClearOnlyPropertyBehavior
public void CanClearOnlyPropertyBehavior()
{
MockRepository mocks = new MockRepository();
IDemo mock = mocks.StrictMock<IDemo>();
Expect.Call(mock.Prop).PropertyBehavior();
mocks.BackToRecord(mock,BackToRecordOptions.PropertyBehavior);
mocks.ReplayAll();
Assert.Throws<ExpectationViolationException>("IDemo.get_Prop(); Expected #0, Actual #1.", delegate
{
string prop = mock.Prop;
});
}
示例7: BackToRecordOnADynamicMock
public void BackToRecordOnADynamicMock()
{
MockRepository repository = new MockRepository();
ITest test = (ITest)repository.DynamicMock(typeof(ITest));
test.DoSomething(1);
repository.BackToRecord(test);
test.DoSomething(2);
repository.ReplayAll();
test.DoSomething(2);
test.DoSomething(3);
repository.VerifyAll();
}
示例8: CanMoveToRecordFromReplyWithoutClearingExpectations
public void CanMoveToRecordFromReplyWithoutClearingExpectations()
{
MockRepository mocks = new MockRepository();
IDemo mock = mocks.StrictMock<IDemo>();
mock.VoidNoArgs();
mocks.ReplayAll();
mocks.BackToRecord(mock, BackToRecordOptions.None);
mock.VoidNoArgs();
mocks.ReplayAll();
mock.VoidNoArgs();
mocks.VerifyAll();
}
示例9: CanSpecifyClearOnlyEvents
public void CanSpecifyClearOnlyEvents()
{
MockRepository mocks = new MockRepository();
IWithEvent withEvent = mocks.StrictMock<IWithEvent>();
bool called = false;
withEvent.Load += delegate { called = true; };
IEventRaiser raiser = LastCall.GetEventRaiser();
mocks.BackToRecord(withEvent, BackToRecordOptions.EventSubscribers);
raiser.Raise(this, EventArgs.Empty);
Assert.IsFalse(called);
}
示例10: CanMoveToRecordFromReplyWithoutClearingExpectations
public void CanMoveToRecordFromReplyWithoutClearingExpectations()
{
MockRepository mocks = new MockRepository();
IDemo mock = mocks.StrictMock<IDemo>();
mock.VoidNoArgs();
mocks.ReplayAll();
mocks.BackToRecord(mock, BackToRecordOptions.None);
mock.VoidNoArgs();
mocks.ReplayAll();
mock.VoidNoArgs();
string expectedMessage = "IDemo.VoidNoArgs(); Expected #1, Actual #0.";
ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
() => mocks.VerifyAll());
Assert.Equal(expectedMessage, ex.Message);
}