public void Ctor()
        {
            // arrange
            var property = Mock.Create<IPropertyInfo>(Behavior.RecursiveLoose);

            var inputProperties = new List<IPropertyInfo> { property };

            // act
            var rule = new RichTextMaxLengthRule(property, 1);

            // assert
            CollectionAssert.AreEqual(inputProperties, rule.InputProperties);
            Assert.AreEqual(1, new PrivateAccessor(rule).GetField("_numberOfCharacters"));
        }
        public void Execute()
        {
            // arrange
            var rule = new RichTextMaxLengthRule(null, 0);
            var privateAccessor = new PrivateAccessor(rule);

            // act
            try
            {
                privateAccessor.CallMethod("Execute", new object[] { null });
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }

            // arrange
            var property = Mock.Create<IPropertyInfo>(Behavior.RecursiveLoose);

            var context = Mock.Create<RuleContext>(Constructor.Mocked, Behavior.CallOriginal);
            Mock.Arrange(() => context.InputPropertyValues).Returns(new Dictionary<IPropertyInfo, object>
                {
                    { property, string.Empty }
                });

            rule.PrimaryProperty = property;

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

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

            // assert
            Assert.IsFalse(ruleWasThrown);

            // arrange
            Mock.Arrange(() => context.InputPropertyValues).Returns(new Dictionary<IPropertyInfo, object>
                {
                    { property, "Hello World!" + Constants.InvokeRichTextMaxLengthRule }
                });

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

            // assert
            Assert.IsTrue(ruleWasThrown);
        }