当前位置: 首页>>代码示例>>C#>>正文


C# RuleContext.GetPropertyName方法代码示例

本文整理汇总了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));
		}
开发者ID:kamilkk,项目名称:MyVote,代码行数:21,代码来源:PollSubmissionPollStartDateRuleTests.cs

示例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);
		}
开发者ID:kamilkk,项目名称:MyVote,代码行数:21,代码来源:PollSubmissionPollDeletedFlagRuleTests.cs

示例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();
		}
开发者ID:JacobAtchley,项目名称:MyVote,代码行数:23,代码来源:PollSubmissionPollStartDateRuleTests.cs

示例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();
		}
开发者ID:JacobAtchley,项目名称:MyVote,代码行数:23,代码来源:PollSubmissionPollDeletedFlagRuleTests.cs


注:本文中的RuleContext.GetPropertyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。