Ejemplo n.º 1
0
        public void Execute()
        {
            // arrange
            var rule = new ScheduleStateRule(null, null);

            var context = Mock.Create<RuleContext>(Constructor.Mocked, Behavior.CallOriginal);
            Mock.Arrange(() => context.InputPropertyValues)
                .Returns(new Dictionary<IPropertyInfo, object> { { ProcessScheduleEdit.HighlightScheduleStateProperty, 0 }, { ProcessScheduleEdit.ScheduleStartStateGuidProperty, Guid.Empty } });

            var ruleWasThrown = false;
            Mock.Arrange(() => context.AddErrorResult(Arg.IsAny<IPropertyInfo>(), Arg.AnyString)).DoInstead(() => ruleWasThrown = true);

            // act
            var privateAccessor = new PrivateAccessor(rule);
            privateAccessor.CallMethod("Execute", new object[] { context });

            // assert
            Assert.IsTrue(ruleWasThrown);

            // arrange
            ruleWasThrown = false;
            Mock.Arrange(() => context.InputPropertyValues)
                .Returns(new Dictionary<IPropertyInfo, object> { { ProcessScheduleEdit.HighlightScheduleStateProperty, 0 }, { ProcessScheduleEdit.ScheduleStartStateGuidProperty, Guid.NewGuid() } });

            // act
            privateAccessor.CallMethod("Execute", new object[] { context });

            // assert
            Assert.IsFalse(ruleWasThrown);
        }
Ejemplo n.º 2
0
        public void Ctor()
        {
            // arrange
            var inputProperties = new List<IPropertyInfo> { ProcessScheduleEdit.HighlightScheduleStateProperty, ProcessScheduleEdit.ScheduleStartStateGuidProperty };
            var affectedProperties = new List<IPropertyInfo> { ProcessScheduleEdit.HighlightScheduleStateProperty, ProcessScheduleEdit.ScheduleStartStateGuidProperty };

            // act
            var rule = new ScheduleStateRule(ProcessScheduleEdit.HighlightScheduleStateProperty, ProcessScheduleEdit.ScheduleStartStateGuidProperty);

            // assert
            CollectionAssert.AreEqual(inputProperties, rule.InputProperties);
            CollectionAssert.AreEqual(affectedProperties, rule.AffectedProperties);
        }