Ejemplo n.º 1
0
        public void Crn_FormatErrorMessage_ReturnsFormattedErrorMessage()
        {
            var sut = new CrnAttribute();

            var error = sut.FormatErrorMessage("property");

            Assert.IsTrue(!string.IsNullOrEmpty(error));
        }
Ejemplo n.º 2
0
        public void Crn_FormatErrorMessageWithErrorMessage_ReturnsFormattedErrorMessage()
        {
            var sut = new CrnAttribute();

            sut.ErrorMessage = "My error.";

            var error = sut.FormatErrorMessage("property");

            Assert.IsTrue(error == "My error.");
        }
Ejemplo n.º 3
0
        public void Crn_FormatErrorMessageWithErrorResource_ReturnsFormattedErrorMessage()
        {
            var sut = new CrnAttribute();

            sut.ErrorMessageResourceName = "CrnAttribute_Invalid";
            sut.ErrorMessageResourceType = typeof(DataAnnotationsResources);

            var error = sut.FormatErrorMessage("property");

            Assert.IsTrue(error == string.Format(DataAnnotationsResources.CrnAttribute_Invalid, "property"));
        }
Ejemplo n.º 4
0
        public void Crn_ValidValue_Validates()
        {
            var sut = new CrnAttribute();

            Assert.IsTrue(sut.IsValid("123456789T"));
        }
Ejemplo n.º 5
0
        public void Crn_InvalidCharacters_Fails()
        {
            var sut = new CrnAttribute();

            Assert.IsFalse(sut.IsValid("ABCDEFGHIJ"));
        }
Ejemplo n.º 6
0
        public void Crn_InvalidLength_Fails()
        {
            var sut = new CrnAttribute();

            Assert.IsFalse(sut.IsValid("123"));
        }
Ejemplo n.º 7
0
        public void Crn_InvalidChecksum_Fails()
        {
            var sut = new CrnAttribute();

            Assert.IsFalse(sut.IsValid("123456789X"));
        }
Ejemplo n.º 8
0
        public void Crn_EmptyValue_Validates()
        {
            var sut = new CrnAttribute();

            Assert.IsTrue(sut.IsValid(string.Empty));
        }
Ejemplo n.º 9
0
        public void Crn_NullValue_Validates()
        {
            var sut = new CrnAttribute();

            Assert.IsTrue(sut.IsValid(null));
        }