本文整理汇总了C#中RuleContext.GetPropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# RuleContext.GetPropertyName方法的具体用法?C# RuleContext.GetPropertyName怎么用?C# RuleContext.GetPropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleContext
的用法示例。
在下文中一共展示了RuleContext.GetPropertyName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteWhenStartDateIsBeforeNow
public void ExecuteWhenStartDateIsBeforeNow()
{
var pollStartDateProperty = new Mock<IPropertyInfo>();
pollStartDateProperty.Setup(_ => _.Name).Returns("PollStartDate");
var isActiveProperty = new Mock<IPropertyInfo>();
isActiveProperty.Setup(_ => _.Name).Returns("IsActive");
var rule = new PollSubmissionPollStartDateRule(
pollStartDateProperty.Object, isActiveProperty.Object);
var context = new RuleContext(null, rule, null,
new Dictionary<IPropertyInfo, object>
{
{ pollStartDateProperty.Object, DateTime.UtcNow.AddDays(-2) },
{ isActiveProperty.Object, true }
});
(rule as IBusinessRule).Execute(context);
Assert.AreEqual(0, context.Results.Count, context.GetPropertyName(_ => _.Results));
Assert.IsNull(context.OutputPropertyValues, context.GetPropertyName(_ => _.OutputPropertyValues));
}
示例2: ExecuteWhenFlagIsNotNullAndFalse
public void ExecuteWhenFlagIsNotNullAndFalse()
{
var pollDeletedFlagProperty = new Mock<IPropertyInfo>();
pollDeletedFlagProperty.Setup(_ => _.Name).Returns("PollDeletedFlag");
var isActiveProperty = new Mock<IPropertyInfo>();
isActiveProperty.Setup(_ => _.Name).Returns("IsActive");
var rule = new PollSubmissionPollDeletedFlagRule(
pollDeletedFlagProperty.Object, isActiveProperty.Object);
var context = new RuleContext(null, rule, null,
new Dictionary<IPropertyInfo, object>
{
{ pollDeletedFlagProperty.Object, false },
{ isActiveProperty.Object, true }
});
(rule as IBusinessRule).Execute(context);
Assert.AreEqual(0, context.Results.Count, context.GetPropertyName(_ => _.Results));
Assert.IsNull(context.OutputPropertyValues);
}
示例3: ExecuteWhenStartDateIsAfterNow
public void ExecuteWhenStartDateIsAfterNow()
{
var pollStartDateProperty = new Mock<IPropertyInfo>(MockBehavior.Strict);
pollStartDateProperty.Setup(_ => _.Name).Returns("PollStartDate");
var isActiveProperty = Mock.Of<IPropertyInfo>();
var rule = new PollSubmissionPollStartDateRule(
pollStartDateProperty.Object, isActiveProperty);
var context = new RuleContext(null, rule, null,
new Dictionary<IPropertyInfo, object>
{
{ pollStartDateProperty.Object, DateTime.UtcNow.AddDays(2) },
{ isActiveProperty, true }
});
(rule as IBusinessRule).Execute(context);
Assert.AreEqual(1, context.Results.Count, context.GetPropertyName(_ => _.Results));
Assert.IsFalse((bool)context.OutputPropertyValues[isActiveProperty]);
pollStartDateProperty.VerifyAll();
}
示例4: ExecuteWhenFlagIsNull
public void ExecuteWhenFlagIsNull()
{
var pollDeletedFlagProperty = new Mock<IPropertyInfo>(MockBehavior.Strict);
pollDeletedFlagProperty.SetupGet(_ => _.Name).Returns("PollDeletedFlag");
var isActiveProperty = Mock.Of<IPropertyInfo>();
var rule = new PollSubmissionPollDeletedFlagRule(
pollDeletedFlagProperty.Object, isActiveProperty);
var context = new RuleContext(null, rule, null,
new Dictionary<IPropertyInfo, object>
{
{ pollDeletedFlagProperty.Object, (null as int?) },
{ isActiveProperty, true }
});
(rule as IBusinessRule).Execute(context);
Assert.AreEqual(0, context.Results.Count, context.GetPropertyName(_ => _.Results));
Assert.IsNull(context.OutputPropertyValues);
pollDeletedFlagProperty.VerifyAll();
}