Ejemplo n.º 1
0
        public void IsValidThrowsExceptionIfPropertyNameIsNotSet()
        {
            // Arrange
            var r = new RequiredRule("ARuleName");

            // Act
            r.IsValid(new Dictionary <string, string>()
            {
                { "AProperty", "Blah" }
            });
        }
Ejemplo n.º 2
0
        public void IsValidReturnsTrueWithNonNullString()
        {
            // Arrange
            var r = new RequiredRule("ARuleName").Property("APropertyName");

            // Act
            var result = r.IsValid(new Dictionary <string, string>(1)
            {
                { "APropertyName", "This is not a null string." }
            });

            // Assert
            Assert.IsTrue(result);
            Assert.IsNull(r.ErrorMessage);
        }
Ejemplo n.º 3
0
        private void TestIsValidWithNullEquivalent(string Value)
        {
            // Arrange
            var r = new RequiredRule("ARuleName").Property("APropertyName");

            // Act
            var result = r.IsValid(new Dictionary <string, string>(1)
            {
                { "APropertyName", Value }
            });

            // Assert
            Assert.IsFalse(result);
            Assert.AreEqual("APropertyName is required, but is null, an empty string, or whitespace.",
                            r.ErrorMessage);
        }