本文整理汇总了C#中Builder.Do方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.Do方法的具体用法?C# Builder.Do怎么用?C# Builder.Do使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Builder
的用法示例。
在下文中一共展示了Builder.Do方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVerifyWithSequenceOfActionsTestCases
public IEnumerable<TestCaseData> GetVerifyWithSequenceOfActionsTestCases()
{
var builder = new Builder<ILogWriter>();
yield return builder.Do(lw => lw.Write(42))
.Do(lw => lw.Write(42))
.Expects(lw => lw.Write(42), Times.Exactly(2));
}
示例2: GetVerifyWithOneFuncTestCases
public static IEnumerable<TestCaseData> GetVerifyWithOneFuncTestCases()
{
var builder = new Builder<ILogWriter>();
// Test cases for ILogWriter.WriteR(int)
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(42));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(42));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(It.IsAny<int>()));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(It.IsInRange(41, 43)));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(It.IsInRange(44, 46)),
Times.Never());
// Failure cases
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(21))
.Throws(typeof(VerificationException));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(It.IsInRange(43, 44)))
.Throws(typeof(VerificationException));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(42), Times.Never())
.Throws(typeof(VerificationException));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(42), Times.AtLeast(2))
.Throws(typeof(VerificationException));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(42), Times.Exactly(2))
.Throws(typeof(VerificationException));
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.ToString().Length)
.Throws(typeof(InvalidOperationException));
// Test cases for ILogWriter.WriteR(string)
yield return builder.Do(lw => lw.WriteR("foo")).Expects(lw => lw.WriteR("foo"));
yield return builder.Do(lw => lw.WriteR("foo")).Expects(lw => lw.WriteR(It.IsAny<string>()));
// Test cases for ILogWriter.WriteR(int, string)
yield return builder.Do(lw => lw.WriteR(42, "Foo")).Expects(lw => lw.WriteR(42, "Foo"));
yield return builder.Do(lw => lw.WriteR(42, "Foo"))
.Expects(lw => lw.WriteR(It.IsAny<int>(), It.IsAny<string>()));
yield return builder.Do(lw => lw.WriteR(42, "Foo"))
.Expects(lw => lw.WriteR(It.IsInRange(1, 43), It.IsAny<string>()));
// Tests cases with predicate-base verification
yield return builder.Do(lw => lw.WriteR(42)).Expects(lw => lw.WriteR(It.Is<int>(n => n == 42)));
yield return builder.Do(lw => lw.WriteR("Foooo"))
.Expects(lw => lw.WriteR(It.Is<string>(s => s.ToLower().StartsWith("foo"))));
}