Ejemplo n.º 1
0
		public void Defaults ()
		{
			var dv = new PokerDynamicValidator ();

			Assert.IsNull (dv.Column, "#A1");
			Assert.IsNotNull (dv.ColumnName, "#A2");
			Assert.AreEqual (String.Empty, dv.ColumnName, "#A2-1");
			Assert.IsNull (dv.GetValidationException (), "#A3");
		}
Ejemplo n.º 2
0
		public void Column ()
		{
			MetaModel m = Utils.CommonInitialize ();
			MetaTable t = m.Tables[TestDataContext.TableBazColumnAttributes];
			MetaColumn mc = t.GetColumn ("ColumnNoAttributes");

			var dv = new PokerDynamicValidator ();
			Assert.IsNull (dv.Column, "#A1");

			dv.Column = mc;
			Assert.IsNotNull (dv.Column, "#B1");
			Assert.AreEqual (mc, dv.Column, "#B1-1");

			dv.Column = null;
			Assert.IsNull (dv.Column, "#C1");
		}
Ejemplo n.º 3
0
		public void ValidateException ()
		{
			var dv = new PokerDynamicValidator ();

			dv.CallValidateException (null);

			Assert.IsNull (dv.GetValidationException (), "#A1");
			Exception ex = new Exception ();
			dv.CallValidateException (ex);
			Assert.IsNull (dv.GetValidationException (), "#B1");

			ex = new ValidationException ("test message");
			dv.CallValidateException (ex);
			Assert.IsNotNull (dv.GetValidationException (), "#C1");
			Assert.AreEqual (ex, dv.GetValidationException (), "#C1-1");
			Assert.AreEqual ("test message", dv.GetValidationException ().Message, "#C1-2");
		}
Ejemplo n.º 4
0
		public void ValidationException ()
		{
			var dv = new PokerDynamicValidator ();

			Assert.IsNull (dv.GetValidationException (), "#A1");

			Exception ex = new Exception ();
			dv.SetValidationException (ex);
			Assert.AreEqual (ex, dv.GetValidationException (), "#B1");

			ex = new ArgumentNullException ();
			dv.SetValidationException (ex);
			Assert.AreEqual (ex, dv.GetValidationException (), "#C1");

			dv.SetValidationException (null);
			Assert.IsNull (dv.GetValidationException (), "#D1");
		}
Ejemplo n.º 5
0
		public void EvaluateIsValid ()
		{
			var dv = new PokerDynamicValidator ();

			Assert.IsTrue (dv.CallEvaluateIsValid (), "#A1");
			Assert.IsNotNull (dv.ControlToValidate, "#A1-1");
			Assert.AreEqual (String.Empty, dv.ControlToValidate, "#A1-2");
			Assert.AreEqual (String.Empty, dv.ErrorMessage, "#A1-3");

			dv.SetValidationException (new Exception ("test message"));
			Assert.IsFalse (dv.CallEvaluateIsValid (), "#A2");
			Assert.AreEqual (dv.GetValidationException ().Message, dv.ErrorMessage, "#A2-1");

			dv.SetValidationException (new Exception ("<script>message</script>"));
			Assert.IsFalse (dv.CallEvaluateIsValid (), "#A3");
			Assert.AreEqual (HttpUtility.HtmlEncode (dv.GetValidationException ().Message), dv.ErrorMessage, "#A3-1");
		}
Ejemplo n.º 6
0
		public void ControlPropertiesValid ()
		{
			var dv = new PokerDynamicValidator ();

			// Nice...:
			//
			// MonoTests.System.Web.DynamicData.DynamicValidatorTest.ControlPropertiesValid:
			// System.NullReferenceException : Object reference not set to an instance of an object.
			// at System.Web.DynamicData.DynamicDataExtensions.FindDataSourceControl(Control current)
			// at System.Web.DynamicData.DynamicValidator.get_DynamicDataSource()
			// at System.Web.DynamicData.DynamicValidator.ControlPropertiesValid()
			// at MonoTests.Common.PokerDynamicValidator.CallControlPropertiesValid() in C:\Users\grendel\Documents\Visual Studio 2008\Projects\DynamicDataNunit\DynamicDataNunitTests\Common\PokerDynamicValidator.cs:line 20
			// at MonoTests.System.Web.DynamicData.DynamicValidatorTest.ControlPropertiesValid() in C:\Users\grendel\Documents\Visual Studio 2008\Projects\DynamicDataNunit\DynamicDataNunitTests\System.Web.DynamicData\DynamicValidatorTest.cs:line 220
			// Assert.IsFalse (dv.CallControlPropertiesValid (), "#A1");
		}
Ejemplo n.º 7
0
		public void ColumnName ()
		{
			MetaModel m = Utils.CommonInitialize ();
			MetaTable t = m.Tables[TestDataContext.TableBazColumnAttributes];
			MetaColumn mc = t.GetColumn ("ColumnNoAttributes");

			var dv = new PokerDynamicValidator ();
			Assert.AreEqual (String.Empty, dv.ColumnName, "#A1");

			dv.Column = mc;
			Assert.AreEqual (mc.Name, dv.ColumnName, "#B1");
		}