GetErrorMessageString() public method

public GetErrorMessageString ( ) : string
return string
        public void Constructor_Func()
        {
            var attr = new ValidateFooAttribute(ErrorMessageAccessor);

            Assert.IsNull(attr.ErrorMessage, "#A1");
            Assert.IsNull(attr.ErrorMessageResourceName, "#A2");
            Assert.IsNull(attr.ErrorMessageResourceType, "#A3");
            Assert.IsNotNull(attr.GetErrorMessageString(), "#A4");
            Assert.AreEqual(TEST_ERROR_MESSAGE, attr.GetErrorMessageString(), "#A4");
        }
Example #2
0
		public void Constructor_Func ()
		{
			var attr = new ValidateFooAttribute (ErrorMessageAccessor);

			Assert.IsNull (attr.ErrorMessage, "#A1");
			Assert.IsNull (attr.ErrorMessageResourceName, "#A2");
			Assert.IsNull (attr.ErrorMessageResourceType, "#A3");
			Assert.IsNotNull (attr.GetErrorMessageString (), "#A4");
			Assert.AreEqual (TEST_ERROR_MESSAGE, attr.GetErrorMessageString (), "#A4");
		}
Example #3
0
		public void Constructor_String ()
		{
			var attr = new ValidateFooAttribute ("Another Test Error Message");

			Assert.IsNull (attr.ErrorMessage, "#A1");
			Assert.IsNull (attr.ErrorMessageResourceName, "#A2");
			Assert.IsNull (attr.ErrorMessageResourceType, "#A3");
			Assert.IsNotNull (attr.GetErrorMessageString (), "#A4");
			Assert.IsNotNull (attr.GetErrorMessageString (), "#A4-1");
			Assert.AreEqual ("Another Test Error Message", attr.GetErrorMessageString (), "#A4-2");
		}
        public void Constructor_String()
        {
            var attr = new ValidateFooAttribute("Another Test Error Message");

            Assert.IsNull(attr.ErrorMessage, "#A1");
            Assert.IsNull(attr.ErrorMessageResourceName, "#A2");
            Assert.IsNull(attr.ErrorMessageResourceType, "#A3");
            Assert.IsNotNull(attr.GetErrorMessageString(), "#A4");
            Assert.IsNotNull(attr.GetErrorMessageString(), "#A4-1");
            Assert.AreEqual("Another Test Error Message", attr.GetErrorMessageString(), "#A4-2");
        }
Example #5
0
		public void Constructor ()
		{
			var attr = new ValidateFooAttribute ();

			Assert.IsNull (attr.ErrorMessage, "#A1");
			Assert.IsNull (attr.ErrorMessageResourceName, "#A2");
			Assert.IsNull (attr.ErrorMessageResourceType, "#A3");
			Assert.IsNotNull (attr.GetErrorMessageString (), "#A4");
		}
        public void Constructor()
        {
            var attr = new ValidateFooAttribute();

            Assert.IsNull(attr.ErrorMessage, "#A1");
            Assert.IsNull(attr.ErrorMessageResourceName, "#A2");
            Assert.IsNull(attr.ErrorMessageResourceType, "#A3");
            Assert.IsNotNull(attr.GetErrorMessageString(), "#A4");
        }
Example #7
0
		public void ErrorMessageString ()
		{
			var attr = new ValidateFooAttribute ();

			Assert.IsNotNull (attr.GetErrorMessageString (), "#A1-1");
			Assert.IsTrue (attr.GetErrorMessageString ().Length > 0, "#A1-2");

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "TestResource";
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A2-1");
			} catch (InvalidOperationException) {
				// success
			}
#if NET_4_0
			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = String.Empty;
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A2-1");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			attr.ErrorMessageResourceName = null;
			
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A3-1");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = String.Empty;
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				string s = attr.GetErrorMessageString ();
				Assert.Fail ("#A3-2");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "NoSuchProperty";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A4");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorProperty2";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A5");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorProperty3";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A5");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorProperty4";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A6");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorProperty5";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#A7");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorField1";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#B1");
			} catch (InvalidOperationException) {
				// success
			}

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorField2";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#B2");
			} catch (InvalidOperationException) {
				// success
			}
#endif

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorProperty1";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			Assert.IsNotNull (attr.GetErrorMessageString (), "#C1-1");
			Assert.AreEqual ("Error Message 1", attr.GetErrorMessageString (), "#C1-2");

			attr = new ValidateFooAttribute (ErrorMessageAccessor);
			Assert.IsNotNull (attr.GetErrorMessageString (), "#D1-1");
			Assert.AreEqual (TEST_ERROR_MESSAGE, attr.GetErrorMessageString (), "#D1-2");

			attr = new ValidateFooAttribute ();
			attr.ErrorMessageResourceName = "ErrorProperty1";
			attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
			Assert.IsNotNull (attr.GetErrorMessageString (), "#D1-3");
			Assert.AreEqual ("Error Message 1", attr.GetErrorMessageString (), "#D1-4");
#if NET_4_0
			attr.ErrorMessage = "Test Message";
			try {
				attr.GetErrorMessageString ();
				Assert.Fail ("#E1");
			} catch (InvalidOperationException) {
				// success
			}
#endif
		}
        public void ErrorMessageString()
        {
            var attr = new ValidateFooAttribute();

            Assert.IsNotNull(attr.GetErrorMessageString(), "#A1-1");
            Assert.IsTrue(attr.GetErrorMessageString().Length > 0, "#A1-2");

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "TestResource";
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A2-1");
            } catch (InvalidOperationException) {
                // success
            }
#if NET_4_0
            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = String.Empty;
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A2-1");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            attr.ErrorMessageResourceName = null;

            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A3-1");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = String.Empty;
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                string s = attr.GetErrorMessageString();
                Assert.Fail("#A3-2");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "NoSuchProperty";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A4");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorProperty2";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A5");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorProperty3";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A5");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorProperty4";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A6");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorProperty5";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#A7");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorField1";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#B1");
            } catch (InvalidOperationException) {
                // success
            }

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorField2";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#B2");
            } catch (InvalidOperationException) {
                // success
            }
#endif

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorProperty1";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            Assert.IsNotNull(attr.GetErrorMessageString(), "#C1-1");
            Assert.AreEqual("Error Message 1", attr.GetErrorMessageString(), "#C1-2");

            attr = new ValidateFooAttribute(ErrorMessageAccessor);
            Assert.IsNotNull(attr.GetErrorMessageString(), "#D1-1");
            Assert.AreEqual(TEST_ERROR_MESSAGE, attr.GetErrorMessageString(), "#D1-2");

            attr = new ValidateFooAttribute();
            attr.ErrorMessageResourceName = "ErrorProperty1";
            attr.ErrorMessageResourceType = typeof(FooErrorMessageProvider);
            Assert.IsNotNull(attr.GetErrorMessageString(), "#D1-3");
            Assert.AreEqual("Error Message 1", attr.GetErrorMessageString(), "#D1-4");
#if NET_4_0
            attr.ErrorMessage = "Test Message";
            try {
                attr.GetErrorMessageString();
                Assert.Fail("#E1");
            } catch (InvalidOperationException) {
                // success
            }
#endif
        }