本文整理汇总了C#中MockRepository.Unordered方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Unordered方法的具体用法?C# MockRepository.Unordered怎么用?C# MockRepository.Unordered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockRepository
的用法示例。
在下文中一共展示了MockRepository.Unordered方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanUseSetupResultAndIgnoreArguments_WhenUsingUnorderedBlock
public void CanUseSetupResultAndIgnoreArguments_WhenUsingUnorderedBlock()
{
MockRepository mocks = new MockRepository();
IFetcher fetcher = mocks.DynamicMock<IFetcher>();
using (mocks.Unordered())
{
SetupResult.For(fetcher.GetUsersWithCriteriaLike(null)).IgnoreArguments().Return(
new Student[] {new Student(), new Student()});
}
mocks.ReplayAll();
Assert.Equal(2, fetcher.GetUsersWithCriteriaLike("foo").Length);
}
示例2: NestedInorderedAndAtLeastOnce
public void NestedInorderedAndAtLeastOnce()
{
MockRepository mocks = new MockRepository();
IMyObject myObject = mocks.StrictMock(typeof(IMyObject)) as IMyObject;
using (mocks.Ordered())
{
using (mocks.Unordered()) // <-- Works only if ordered
{
Expect.Call(myObject.SomeProperty).Return(null).Repeat.AtLeastOnce();
}
myObject.DoSomething();
}
mocks.ReplayAll();
Assert.IsNull(myObject.SomeProperty);
Assert.IsNull(myObject.SomeProperty);
Assert.IsNull(myObject.SomeProperty);
myObject.DoSomething();
mocks.VerifyAll();
}
示例3: UnorderedAndAtLeastOnce_CallingAnExtraMethod
public void UnorderedAndAtLeastOnce_CallingAnExtraMethod()
{
MockRepository mocks = new MockRepository();
IMyObject myObject = mocks.StrictMock(typeof(IMyObject)) as IMyObject;
using (mocks.Unordered())
{
Expect.Call(myObject.SomeProperty).Return(null).Repeat.AtLeastOnce();
}
myObject.DoSomethingElse();
mocks.ReplayAll();
Assert.IsNull(myObject.SomeProperty);
Assert.IsNull(myObject.SomeProperty);
Assert.IsNull(myObject.SomeProperty);
myObject.DoSomething();
mocks.VerifyAll();
}
示例4: UnorderedAndAtLeastOnce_CallingAnExtraMethod
public void UnorderedAndAtLeastOnce_CallingAnExtraMethod()
{
MockRepository mocks = new MockRepository();
IMyObject myObject = mocks.StrictMock(typeof(IMyObject)) as IMyObject;
using (mocks.Unordered())
{
Expect.Call(myObject.SomeProperty).Return(null).Repeat.AtLeastOnce();
}
myObject.DoSomethingElse();
mocks.ReplayAll();
Assert.Null(myObject.SomeProperty);
Assert.Null(myObject.SomeProperty);
Assert.Null(myObject.SomeProperty);
Assert.Throws<ExpectationViolationException>(
@"IMyObject.DoSomething(); Expected #0, Actual #1.",
() => myObject.DoSomething());
}
示例5: ConfigureOrderedTimesMin0WithNestedUnordered
private static void ConfigureOrderedTimesMin0WithNestedUnordered(MockRepository mocks, I1 mockObject)
{
using (mocks.Ordered())
{
mockObject.A();
LastCall.Repeat.Times(0, 1);
using (mocks.Unordered())
{
mockObject.B();
mockObject.C();
}
mockObject.A();
LastCall.Repeat.Times(0, 1);
}
}
示例6: SetupResultWithNestedOrdering
public void SetupResultWithNestedOrdering()
{
MockRepository mocks = new MockRepository();
ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));
SetupResult.On(maleBird).Call(maleBird.Sing()).Return("");
using (mocks.Ordered())
{
using (mocks.Unordered())
{
maleBird.Eat("seeds", 250);
femaleBird.Eat("seeds", 250);
}
using (mocks.Unordered())
{
maleBird.Mate(femaleBird);
femaleBird.Mate(maleBird);
}
}
mocks.ReplayAll();
maleBird.Sing();
femaleBird.Eat("seeds", 250);
maleBird.Sing();
maleBird.Eat("seeds", 250);
maleBird.Sing();
femaleBird.Mate(maleBird);
maleBird.Sing();
maleBird.Mate(femaleBird);
maleBird.Sing();
mocks.VerifyAll();
}
示例7: OrderedExecutionOfUnorderedSequence
public void OrderedExecutionOfUnorderedSequence()
{
MockRepository mocks = new MockRepository();
ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));
using (mocks.Ordered())
{
using (mocks.Unordered())
{
maleBird.Eat("seeds", 250);
femaleBird.Eat("seeds", 250);
}
using (mocks.Unordered())
{
maleBird.Mate(femaleBird);
femaleBird.Mate(maleBird);
}
}
mocks.ReplayAll();
femaleBird.Eat("seeds", 250);
maleBird.Eat("seeds", 250);
femaleBird.Mate(maleBird);
maleBird.Mate(femaleBird);
mocks.VerifyAll();
}
示例8: ExampleUsingCallbacks
public void ExampleUsingCallbacks()
{
MockRepository mocks = new MockRepository();
ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));
using (mocks.Ordered())
{
using (mocks.Unordered())
{
maleBird.MoveToCage(null);
LastCall.On(maleBird).Callback(new CageDelegate(IsSameCage));
femaleBird.MoveToCage(null);
LastCall.On(femaleBird).Callback(new CageDelegate(IsSameCage));
}
maleBird.Eat("seeds", 250);
femaleBird.Eat("seeds", 250);
using (mocks.Unordered())
{
maleBird.Mate(femaleBird);
femaleBird.Mate(maleBird);
}
}
mocks.ReplayAll();
BirdVeterinary vet = new BirdVeterinary();
vet.Mate(maleBird, femaleBird);
mocks.VerifyAll();
}
示例9: SubmitDataToDB
public void SubmitDataToDB()
{
//Setup a mock view and ISumbition
MockRepository mocks = new MockRepository();
IView myMockView = (IView) mocks.DynamicMock(typeof (IView));
ISumbition myMockSubmition = (ISumbition) mocks.DynamicMock(typeof (ISumbition));
//Record expectations
SetupResult.For(myMockView.UserID).Return(3105596L);
SetupResult.For(myMockView.Name).Return("Someone");
SetupResult.For(myMockView.Address).Return("Somewhere");
using (mocks.Ordered())
{
using (mocks.Unordered())
{
myMockSubmition.Name = "Someone";
myMockSubmition.Address = "Somewhere";
myMockSubmition.UserID = 3105596L;
}
myMockSubmition.Save();
}
//setup the present
mocks.ReplayAll();
Presneter myPresenter = new Presneter(myMockView, myMockSubmition);
myPresenter.Sumbit();
mocks.VerifyAll();
}