本文整理汇总了C#中Mock.CallTo方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.CallTo方法的具体用法?C# Mock.CallTo怎么用?C# Mock.CallTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.CallTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldThrowMockExceptionWhenExactSequenceIsNotMatched
public void ShouldThrowMockExceptionWhenExactSequenceIsNotMatched()
{
var strictLaterSequence = new StrictSequenceStartingAnywhere();
var a = new Mock<IFoo> {CallSequence = strictLaterSequence};
var b = new Mock<IFoo> {CallSequence = a.CallSequence};
b.Object.Do(200);
Assert.Throws<MockException>(
() => strictLaterSequence.Verify(a.CallTo(x => x.Do(100))));
}
开发者ID:grzesiek-galezowski,项目名称:moq4,代码行数:12,代码来源:VerifyInSequenceFixtureWithStrictCallSequenceStartingAnywhere.cs
示例2: ShouldNotSupportCyclicSequencing
public void ShouldNotSupportCyclicSequencing()
{
var strictLaterSequence = new StrictSequenceStartingAnywhere();
var a = new Mock<IFoo>() { CallSequence = strictLaterSequence };
var b = new Mock<IFoo>() { CallSequence = a.CallSequence };
a.Object.Do(200);
b.Object.Do(100);
Assert.Throws<MockException>(
() => strictLaterSequence.Verify(a.CallTo(m => m.Do(100))));
}
开发者ID:grzesiek-galezowski,项目名称:moq4,代码行数:12,代码来源:VerifyInSequenceFixtureWithStrictCallSequenceStartingAnywhere.cs
示例3: ShouldPassVerificationOfCallsMadeExactlyInTheVerifiedSequence
public void ShouldPassVerificationOfCallsMadeExactlyInTheVerifiedSequence()
{
var strictLaterSequence = new StrictSequenceStartingAnywhere();
var a = new Mock<IFoo>() { CallSequence = strictLaterSequence };
var b = new Mock<IFoo>() { CallSequence = a.CallSequence };
a.Object.Do(100);
b.Object.Do(200);
strictLaterSequence.Verify(
a.CallTo(x => x.Do(100)),
b.CallTo(x => x.Do(200))
);
}
开发者ID:grzesiek-galezowski,项目名称:moq4,代码行数:14,代码来源:VerifyInSequenceFixtureWithStrictCallSequenceStartingAnywhere.cs
示例4: ShouldAllowAMixOfSequencedAndNonSequencedMocks
public void ShouldAllowAMixOfSequencedAndNonSequencedMocks()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
var mock2 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
var mock3 = new Mock<RoleWithSingleSimplestMethod>();
mock1.Object.Do();
mock3.Object.Do();
mock2.Object.Do();
sequence.Verify(
mock1.CallTo(a => a.Do()),
mock2.CallTo(b => b.Do())
);
}
示例5: ShouldIgnoreCallsInbetweenMatchingCalls
public void ShouldIgnoreCallsInbetweenMatchingCalls()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
var mock2 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
var mock3 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
mock1.Object.Do();
mock3.Object.Do();
mock2.Object.Do();
sequence.Verify(
mock1.CallTo(m => m.Do()),
mock2.CallTo(m => m.Do())
);
}
示例6: ShouldNotSupportCyclicSequencing
public void ShouldNotSupportCyclicSequencing()
{
var sequence = new CallSequence(MockBehavior.Strict);
var a = new Mock<IFoo>() { CallSequence = sequence };
var b = new Mock<IFoo>() { CallSequence = sequence };
a.Object.Do(200);
b.Object.Do(100);
Assert.Throws<MockException>(() =>
sequence.Verify(
a.CallTo(m => m.Do(100)),
b.CallTo(m => m.Do(200))
)
);
}
示例7: ShouldMatchCallsInTheRightSequenceButMadeLater
public void ShouldMatchCallsInTheRightSequenceButMadeLater()
{
var sequence = new StrictSequenceStartingAnywhere();
var a = new Mock<IFoo>() { CallSequence = sequence };
var b = new Mock<IFoo>() { CallSequence = sequence };
var c = new Mock<IFoo>() { CallSequence = sequence };
var d = new Mock<IFoo>() { CallSequence = sequence };
a.Object.Do(2);
b.Object.Do(1);
c.Object.Do(2);
d.Object.Do(3);
sequence.Verify(
b.CallTo(m => m.Do(1)),
c.CallTo(m => m.Do(2))
);
}
开发者ID:grzesiek-galezowski,项目名称:moq4,代码行数:18,代码来源:VerifyInSequenceFixtureWithStrictCallSequenceStartingAnywhere.cs
示例8: ShouldPassVerificationOfCallsMadeExactlyInTheVerifiedSequence
public void ShouldPassVerificationOfCallsMadeExactlyInTheVerifiedSequence()
{
var strictSequence = new CallSequence(MockBehavior.Strict);
var a = new Mock<IFoo>()
{
CallSequence = strictSequence
};
var b = new Mock<IFoo>()
{
CallSequence = strictSequence
};
a.Object.Do(100);
b.Object.Do(200);
strictSequence.Verify(
a.CallTo(x => x.Do(100)),
b.CallTo(x => x.Do(200))
);
}
示例9: ShouldThrowExceptionWhenVerifyingCallOrderOnMockWithNullSequence
public void ShouldThrowExceptionWhenVerifyingCallOrderOnMockWithNullSequence()
{
var sequence = CallSequence.None();
var mock1 = new Mock<RoleWithSingleSimplestMethod>()
{
CallSequence = sequence
};
var mock2 = new Mock<RoleWithSingleSimplestMethod>()
{
CallSequence = sequence
};
mock1.Object.Do();
mock2.Object.Do();
Assert.Throws<NoSequenceAssignedException>(
() => sequence.Verify(mock1.CallTo(m => m.Do())
));
}
示例10: ShouldThrowMockExceptionWhenExactSequenceIsNotMatched
public void ShouldThrowMockExceptionWhenExactSequenceIsNotMatched()
{
var strictSequence = new CallSequence(MockBehavior.Strict);
var a = new Mock<IFoo>()
{
CallSequence = strictSequence
};
var b = new Mock<IFoo>()
{
CallSequence = strictSequence
};
b.Object.Do(200);
Assert.Throws<MockException>(() =>
strictSequence.Verify(
a.CallTo(m => m.Do(100))
)
);
}
示例11: ShouldThrowExceptionWhenCallsAreNotMadeInOrderInCallSequence
public void ShouldThrowExceptionWhenCallsAreNotMadeInOrderInCallSequence()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
var mock2 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
mock2.Object.Do();
mock1.Object.Do();
Assert.Throws<MockException>(() =>
sequence.Verify(
mock1.CallTo(m => m.Do()),
mock2.CallTo(m => m.Do())
)
);
}
示例12: ShouldSupportMockChainingWithUnmatchingCalls
public void ShouldSupportMockChainingWithUnmatchingCalls()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleForRecursiveMocking>()
{
CallSequence = sequence,
DefaultValue = DefaultValue.Mock
};
mock1.Object.Do().Do();
sequence.Verify(
mock1.CallTo(m => m.Do().Do())
);
Assert.Throws<MockException>(
() => sequence.Verify(
mock1.CallTo(m => m.Do().Do()),
mock1.CallTo(m => m.Do())
)
);
}
示例13: ShouldRecognizeSequenceOfCallsMadeOnTheSameMock
public void ShouldRecognizeSequenceOfCallsMadeOnTheSameMock()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleWithArgumentAndReturnValue> {CallSequence = sequence};
mock1.Object.Do(1);
mock1.Object.Do(2);
mock1.Object.Do(3);
sequence.Verify(
mock1.CallTo(m => m.Do(2)),
mock1.CallTo(m => m.Do(3))
);
Assert.Throws<MockException>(
() => sequence.Verify(
mock1.CallTo(m => m.Do(2)),
mock1.CallTo(m => m.Do(3)),
mock1.CallTo(m => m.Do(1))
)
);
}
示例14: ShouldProperlyRecognizeNonMatchingArgumentsInSequentialVerification
public void ShouldProperlyRecognizeNonMatchingArgumentsInSequentialVerification()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleWithArgumentAndReturnValue> {CallSequence = sequence};
var mock2 = new Mock<RoleWithArgumentAndReturnValue> {CallSequence = sequence};
mock2.Object.Do(1);
mock1.Object.Do(2);
mock2.Object.Do(3);
Assert.Throws<MockException>(() =>
sequence.Verify(
mock1.CallTo(m => m.Do(2)),
mock2.CallTo(m => m.Do(1))
)
);
}
示例15: ShouldNotThrowAnyExceptionWhenCallsAreMadeInOrderInCallSequence
public void ShouldNotThrowAnyExceptionWhenCallsAreMadeInOrderInCallSequence()
{
var sequence = new CallSequence();
var mock1 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
var mock2 = new Mock<RoleWithSingleSimplestMethod> { CallSequence = sequence };
mock1.Object.Do();
mock2.Object.Do();
sequence.Verify(
mock1.CallTo(m => m.Do()),
mock2.CallTo(m => m.Do())
);
}