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)); }
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); }
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(); }
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(); }