//
// Author:
// Chris Toshok (toshok@novell.com)
+// Yoni Klain (Yonik@mainsoft.com)
//
//
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using MonoTests.SystemWeb.Framework;
namespace MonoTests.System.Web.UI.WebControls
{
}
}
- [TestFixture]
- public class BaseCompareValidatorTest : ValidatorTest {
+ [TestFixture]
+ public class BaseCompareValidatorTest : ValidatorTest
+ {
+
+ [Test]
+ public void DefaultProperties ()
+ {
+ BaseCompareValidatorPoker p = new BaseCompareValidatorPoker ();
+
+ Assert.AreEqual (ValidationDataType.String, p.Type, "CultureInvariantValues");
+#if NET_2_0
+ Assert.AreEqual (false, p.CultureInvariantValues, "CultureInvariantValues");
+#endif
+ }
+
+ [Test]
+ public void AssignProperties ()
+ {
+ BaseCompareValidatorPoker p = new BaseCompareValidatorPoker ();
+
+ p.Type = ValidationDataType.Double;
+ Assert.AreEqual (ValidationDataType.Double, p.Type, "CultureInvariantValues");
+#if NET_2_0
+ p.CultureInvariantValues = true;
+ Assert.AreEqual (true, p.CultureInvariantValues, "CultureInvariantValues");
+#endif
+ }
[Test]
public void ViewState ()
{
BaseCompareValidatorPoker p = new BaseCompareValidatorPoker ();
- p.Type = ValidationDataType.String;
- Assert.AreEqual (p.Type, ValidationDataType.String, "A1");
+ p.Type = ValidationDataType.Double;
+#if NET_2_0
+ p.CultureInvariantValues = true;
+#endif
+
+ BaseCompareValidatorPoker copy = new BaseCompareValidatorPoker ();
+ copy.LoadState (p.SaveState ());
+
+ Assert.AreEqual (ValidationDataType.Double, copy.Type, "A1");
+#if NET_2_0
+ Assert.AreEqual (true, copy.CultureInvariantValues, "A1");
+#endif
}
[Test]
{
BaseCompareValidatorPoker p = new BaseCompareValidatorPoker ();
-#if NET_2_0
- Assert.AreEqual (p.GetCutoffYear(), 29, "E1");
-#else
Assert.AreEqual (p.GetCutoffYear(), 2029, "E1");
-#endif
Assert.AreEqual (p.GetFullYear (29), 2029, "E2");
#if NET_2_0
Assert.AreEqual (p.GetFullYear (30), 1930, "E3");
Thread.CurrentThread.CurrentCulture = new CultureInfo ("af-ZA", false);
Assert.AreEqual (p.GetDateElementOrder (), "ymd", "E6");
}
- }
+#if NET_2_0
+ [Test]
+ public void CultureInvariantValues_1 ()
+ {
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
+ // Current date format --> "dmy"
+ Page p = new Page ();
+
+ CompareValidator v = new CompareValidator ();
+ v.ControlToValidate = "tb1";
+ v.Type = ValidationDataType.Date;
+ v.ValueToCompare = "2005/12/24";
+ v.CultureInvariantValues = true;
+
+ TextBox tb1 = new TextBox ();
+ tb1.ID = "tb1";
+ tb1.Text = "12.24.2005";
+
+ p.Controls.Add (tb1);
+ p.Controls.Add (v);
+
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#1");
+
+ tb1.Text = "12/24/2005";
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#2");
+
+ tb1.Text = "2005.12.24";
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#3");
+
+ tb1.Text = "2005.24.12";
+ v.Validate ();
+ Assert.AreEqual (false, v.IsValid, "CultureInvariantValues#4");
+ }
+
+ [Test]
+ public void CultureInvariantValues_2 ()
+ {
+
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-GB", false);
+ // Current date format --> "dmy"
+ Page p = new Page ();
+
+ CompareValidator v = new CompareValidator ();
+ v.ControlToValidate = "tb1";
+ v.Type = ValidationDataType.Date;
+ v.ValueToCompare = "24/12/2005";
+ v.CultureInvariantValues = false;
+
+ TextBox tb1 = new TextBox ();
+ tb1.ID = "tb1";
+ tb1.Text = "24.12.2005";
+
+ p.Controls.Add (tb1);
+ p.Controls.Add (v);
+
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#1");
+
+ tb1.Text = "24-12-2005";
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#2");
+
+ tb1.Text = "2005/12/24";
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#3");
+
+ tb1.Text = "2005.24.12";
+ v.Validate ();
+ Assert.AreEqual (false, v.IsValid, "CultureInvariantValues#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException(typeof(HttpException))]
+ public void CultureInvariantValues_Exception ()
+ {
+
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-GB", false);
+ // Current date format --> "dmy"
+ Page p = new Page ();
+
+ CompareValidator v = new CompareValidator ();
+ v.ControlToValidate = "tb1";
+ v.Type = ValidationDataType.Date;
+ v.ValueToCompare = "12/24/2005";
+ v.CultureInvariantValues = false;
+
+ TextBox tb1 = new TextBox ();
+ tb1.ID = "tb1";
+ tb1.Text = "24.12.2005";
+
+ p.Controls.Add (tb1);
+ p.Controls.Add (v);
+
+ v.Validate ();
+ Assert.AreEqual (true, v.IsValid, "CultureInvariantValues#1");
+
+ tb1.Text = "24-12-2005";
+ v.Validate ();
+ }
+#endif
+ }
}