コード例 #1
0
        public void Test_IsValid_Should_Return_True_When_Value_Is_Valid_Email()
        {
            var values =
                new[]
            {
                "*****@*****.**", // Equal 50
                "*****@*****.**",                                             // Equal 6
                "*****@*****.**"               // Between 6 and 50
            };

            foreach (var value in values)
            {
                // Arrange
                var attr = new EmailValidateAttribute("Test message");

                // Act
                bool result = attr.IsValid(value);

                // Assert
                Assert.IsTrue(result);
            }
        }
コード例 #2
0
        public void Test_IsValid_Should_Return_False_When_Value_Is_Invalid_Email()
        {
            var values =
                new[]
            {
                "",
                null,
                "*****@*****.**", // Greater than 50
                "[email protected]",                                               // Less than 6
                "_.ahzAHZ19 0АРЯаря[email protected]"                      // Space (invalid character)
            };

            foreach (var value in values)
            {
                // Arrange
                var attr = new EmailValidateAttribute("Test message");

                // Act
                bool result = attr.IsValid(value);

                // Assert
                Assert.IsFalse(result);
            }
        }