本文整理汇总了C#中Moq.Mock.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# Moq.Mock.Expect方法的具体用法?C# Moq.Mock.Expect怎么用?C# Moq.Mock.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moq.Mock
的用法示例。
在下文中一共展示了Moq.Mock.Expect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeMockRuleProvider
private static IRulesProvider MakeMockRuleProvider(Type forModelType, params string[] rulePropertyNames)
{
var ruleset = new RuleSet(rulePropertyNames.ToLookup(x => x, x => (Rule)new RequiredRule()));
var mockProvider = new Moq.Mock<IRulesProvider>();
mockProvider.Expect(x => x.GetRulesFromType(forModelType)).Returns(ruleset);
return mockProvider.Object;
}
示例2: IRuleProvider_Has_GetRulesFromType_Method
public void IRuleProvider_Has_GetRulesFromType_Method()
{
// Arrange
var arbitraryType = this.GetType();
var mockRuleProvider = new Moq.Mock<IRulesProvider>();
mockRuleProvider.Expect(x => x.GetRulesFromType(arbitraryType))
.Returns(RuleSet.Empty);
// Act
var actualResult = mockRuleProvider.Object.GetRulesFromType(arbitraryType);
// Assert
Assert.Same(RuleSet.Empty, actualResult);
}
示例3: GetRulesForType_Can_Handle_Provider_Returning_NULL
public void GetRulesForType_Can_Handle_Provider_Returning_NULL()
{
// Arrange
var mockProvider = new Moq.Mock<IRulesProvider>();
mockProvider.Expect(x => x.GetRulesFromType(typeof(double)))
.Returns((RuleSet)null);
ActiveRuleProviders.Providers.Clear();
ActiveRuleProviders.Providers.Add(mockProvider.Object);
// Act
var rules = ActiveRuleProviders.GetRulesForType(typeof (double));
// Assert
Assert.NotNull(rules);
Assert.Empty(rules.Keys);
}