Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/Microsoft.VisualBasic/Test')
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/.cvsignore1
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/AllTests.cs33
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/ChangeLog8
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/CollectionTest.cs535
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/ConversionTest.cs674
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/DateAndTimeTest.cs388
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/Microsoft.VisualBasic_test.build63
7 files changed, 1702 insertions, 0 deletions
diff --git a/mcs/class/Microsoft.VisualBasic/Test/.cvsignore b/mcs/class/Microsoft.VisualBasic/Test/.cvsignore
new file mode 100644
index 00000000000..6a7461313bb
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/.cvsignore
@@ -0,0 +1 @@
+*.dll
diff --git a/mcs/class/Microsoft.VisualBasic/Test/AllTests.cs b/mcs/class/Microsoft.VisualBasic/Test/AllTests.cs
new file mode 100644
index 00000000000..ba8e35d1604
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/AllTests.cs
@@ -0,0 +1,33 @@
+// MonoTests.AllTests, Microsoft.VisualBasic.dll
+//
+// Author:
+// Mario Martinez (mariom925@home.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using NUnit.Framework;
+
+namespace MonoTests
+{
+ /// <summary>
+ /// Combines all unit tests for the Microsoft.VisualBasic.dll assembly
+ /// into one test suite.
+ /// </summary>
+ public class AllTests : TestCase
+ {
+ public AllTests(string name) : base(name) {}
+ public AllTests() : base("Microsoft.VisualBasic.AllTests") {}
+
+ public static ITest Suite {
+ get {
+ TestSuite suite = new TestSuite();
+ suite.AddTest (Microsoft.VisualBasic.CollectionTest.Suite);
+ suite.AddTest (Microsoft.VisualBasic.ConversionTest.Suite);
+ suite.AddTest (Microsoft.VisualBasic.DateAndTimeTest.Suite);
+
+ return suite;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Microsoft.VisualBasic/Test/ChangeLog b/mcs/class/Microsoft.VisualBasic/Test/ChangeLog
new file mode 100644
index 00000000000..b558398f96d
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/ChangeLog
@@ -0,0 +1,8 @@
+2002/10/28 Nick Drochak <ndrochak@gol.com>
+
+ * DateAndTimeTest.cs: Make tests pass on Windows with .NET
+
+2002-10-23 Nick Drochak <ndrochak@gol.com>
+
+ * DateAndTimeTest.cs: Try to set the culture for these tests and see
+ if that helps. All but one works on my machine.
diff --git a/mcs/class/Microsoft.VisualBasic/Test/CollectionTest.cs b/mcs/class/Microsoft.VisualBasic/Test/CollectionTest.cs
new file mode 100644
index 00000000000..457bc821b75
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/CollectionTest.cs
@@ -0,0 +1,535 @@
+// Collection.cs - NUnit Test Cases for Microsoft.VisualBasic.Collection
+//
+// Author:
+// Chris J. Breisch (cjbreisch@altavista.net)
+//
+// (C) Chris J. Breisch
+//
+
+using NUnit.Framework;
+using System;
+using Microsoft.VisualBasic;
+using System.Collections;
+
+namespace MonoTests.Microsoft.VisualBasic
+{
+
+ public class CollectionTest : TestCase
+ {
+
+ public CollectionTest() : base ("Microsoft.VisualBasic.Collection") {}
+ public CollectionTest(string name) : base(name) {}
+
+ protected override void SetUp() {}
+ protected override void TearDown() {}
+
+ public static ITest Suite {
+ get {
+ return new TestSuite(typeof(CollectionTest));
+ }
+ }
+
+ // Test Constructor
+ public void TestNew ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ AssertNotNull("#N01", c);
+ AssertEquals("#N02", 0, c.Count);
+ }
+
+ // Test Add method with Key == null
+ public void TestAddNoKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add(typeof(int), null, null, null);
+ c.Add(typeof(double), null, null, null);
+ c.Add(typeof(string), null, null, null);
+
+ AssertEquals("#ANK01", 3, c.Count);
+
+ // Collection class is 1-based
+ AssertEquals("#ANK02", typeof(string), c[3]);
+
+ }
+
+ // Test Add method with Key specified
+ public void TestAddKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add("Baseball", "Base", null, null);
+ c.Add("Football", "Foot", null, null);
+ c.Add("Basketball", "Basket", null, null);
+ c.Add("Volleyball", "Volley", null, null);
+
+ AssertEquals("#AK01", 4, c.Count);
+
+ // Collection class is 1-based
+ AssertEquals("#AK02", "Baseball", c[1]);
+ AssertEquals("#AK03", "Volleyball", c["Volley"]);
+
+ }
+
+ // Test Add method with Before specified and Key == null
+ public void TestAddBeforeNoKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add(typeof(int), null, null, null);
+ c.Add(typeof(double), null, 1, null);
+ c.Add(typeof(string), null, 2, null);
+ c.Add(typeof(object), null, 2, null);
+
+ AssertEquals("#ABNK01", 4, c.Count);
+
+ // Collection class is 1-based
+ AssertEquals("#ABNK02", typeof(int), c[4]);
+ AssertEquals("#ABNK03", typeof(double), c[1]);
+ AssertEquals("#ABNK04", typeof(object), c[2]);
+
+ }
+
+ // Test Add method with Before and Key
+ public void TestAddBeforeKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add("Baseball", "Base", null, null);
+ c.Add("Football", "Foot", 1, null);
+ c.Add("Basketball", "Basket", 1, null);
+ c.Add("Volleyball", "Volley", 3, null);
+
+ AssertEquals("#ABK01", 4, c.Count);
+ AssertEquals("#ABK02", "Basketball", c[1]);
+ AssertEquals("#ABK03", "Baseball", c[4]);
+ AssertEquals("#ABK04", "Volleyball", c["Volley"]);
+ AssertEquals("#ABK05", "Football", c["Foot"]);
+
+ }
+
+ // Test Add method with After specified and Key == null
+ public void TestAddAfterNoKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add(typeof(int), null, null, 0);
+ c.Add(typeof(double), null, null, 1);
+ c.Add(typeof(string), null, null, 1);
+ c.Add(typeof(object), null, null, 3);
+
+ AssertEquals("#AANK01", 4, c.Count);
+
+ // Collection class is 1-based
+ AssertEquals("#AANK02", typeof(object), c[4]);
+ AssertEquals("#AANK03", typeof(int), c[1]);
+ AssertEquals("#AANK04", typeof(string), c[2]);
+
+ }
+
+ // Test Add method with After and Key
+ public void TestAddAfterKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add("Baseball", "Base", null, 0);
+ c.Add("Football", "Foot", null, 1);
+ c.Add("Basketball", "Basket", null, 1);
+ c.Add("Volleyball", "Volley", null, 2);
+
+ AssertEquals("#AAK01", 4, c.Count);
+
+ // Collection class is 1-based
+ AssertEquals("#AAK02", "Baseball", c[1]);
+ AssertEquals("#AAK03", "Football", c[4]);
+ AssertEquals("#AAK04", "Basketball", c["Basket"]);
+ AssertEquals("#AAK05", "Volleyball", c["Volley"]);
+ }
+
+ // Test GetEnumerator method
+ public void TestGetEnumerator ()
+ {
+ Collection c;
+ IEnumerator e;
+ object[] o = new object[4] {typeof(int),
+ typeof(double), typeof(string), typeof(object)};
+ int i = 0;
+
+ c = new Collection();
+
+ c.Add(typeof(int), null, null, null);
+ c.Add(typeof(double), null, null, null);
+ c.Add(typeof(string), null, null, null);
+ c.Add(typeof(object), null, null, null);
+
+ e = c.GetEnumerator();
+
+ AssertNotNull("#GE01", e);
+
+ while (e.MoveNext()) {
+ AssertEquals("#GE02." + i.ToString(), o[i], e.Current);
+ i++;
+ }
+
+ e.Reset();
+ e.MoveNext();
+
+ AssertEquals("#GE03", o[0], e.Current);
+
+ }
+
+ // Test GetEnumerator method again, this time using foreach
+ public void Testforeach ()
+ {
+ Collection c;
+ object[] o = new object[4] {typeof(int),
+ typeof(double), typeof(string), typeof(object)};
+ int i = 0;
+
+ c = new Collection();
+
+ c.Add(typeof(int), null, null, null);
+ c.Add(typeof(double), null, null, null);
+ c.Add(typeof(string), null, null, null);
+ c.Add(typeof(object), null, null, null);
+
+
+ foreach (object item in c) {
+ AssertEquals("#fe01." + i.ToString(), o[i], item);
+ i++;
+ }
+
+ }
+
+ // Test Remove method with Index
+ public void TestRemoveNoKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add(typeof(int), null, null, null);
+ c.Add(typeof(double), null, null, null);
+ c.Add(typeof(string), null, null, null);
+ c.Add(typeof(object), null, null, null);
+
+ AssertEquals("#RNK01", 4, c.Count);
+
+ c.Remove(3);
+
+ AssertEquals("#RNK02", 3, c.Count);
+
+ // Collection class is 1-based
+ AssertEquals("#RNK03", typeof(object), c[3]);
+
+ c.Remove(1);
+
+ AssertEquals("#RNK04", 2, c.Count);
+ AssertEquals("#RNK05", typeof(double), c[1]);
+ AssertEquals("#RNK06", typeof(object), c[2]);
+
+ c.Remove(2);
+
+ AssertEquals("#RNK07", 1, c.Count);
+ AssertEquals("#RNK08", typeof(double), c[1]);
+
+ c.Remove(1);
+
+ AssertEquals("#RNK09", 0, c.Count);
+
+ }
+
+ // Test Remove method with Key
+ public void TestRemoveKey ()
+ {
+ Collection c;
+
+ c = new Collection();
+
+ c.Add("Baseball", "Base", null, null);
+ c.Add("Football", "Foot", null, null);
+ c.Add("Basketball", "Basket", null, null);
+ c.Add("Volleyball", "Volley", null, null);
+
+ AssertEquals("#RK01", 4, c.Count);
+
+ c.Remove("Foot");
+
+ AssertEquals("#RK02", 3, c.Count);
+ AssertEquals("#RK03", "Basketball", c["Basket"]);
+
+ // Collection class is 1-based
+ AssertEquals("#RK04", "Volleyball", c[3]);
+
+ c.Remove("Base");
+
+ AssertEquals("#RK05", 2, c.Count);
+ AssertEquals("#RK06", "Basketball", c[1]);
+ AssertEquals("#RK07", "Volleyball", c["Volley"]);
+
+ c.Remove(2);
+
+ AssertEquals("#RK08", 1, c.Count);
+ AssertEquals("#RK09", "Basketball", c[1]);
+ AssertEquals("#RK10", "Basketball", c["Basket"]);
+
+ c.Remove(1);
+
+ AssertEquals("#RK11", 0, c.Count);
+ }
+
+ // Test all the Exceptions we're supposed to throw
+ public void TestException ()
+ {
+ Collection c;
+ bool caughtException = false;
+
+ c = new Collection();
+
+ try {
+ // nothing in Collection yet
+ object o = c[0];
+ }
+ catch (Exception e) {
+ AssertEquals("#E01", typeof(IndexOutOfRangeException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E02", true, caughtException);
+
+ c.Add("Baseball", "Base", null, null);
+ c.Add("Football", "Foot", null, null);
+ c.Add("Basketball", "Basket", null, null);
+ c.Add("Volleyball", "Volley", null, null);
+
+ caughtException = false;
+
+ try {
+ // only 4 elements
+ object o = c[5];
+ }
+ catch (Exception e) {
+ AssertEquals("#E03", typeof(IndexOutOfRangeException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E04", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // Collection class is 1-based
+ object o = c[0];
+ }
+ catch (Exception e) {
+ AssertEquals("#E05", typeof(IndexOutOfRangeException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E06", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // no member with Key == "Kick"
+ object o = c["Kick"];
+ }
+ catch (Exception e) {
+ // FIXME
+ // VB Language Reference says IndexOutOfRangeException
+ // here, but MS throws ArgumentException
+ // AssertEquals("#E07", typeof(IndexOutOfRangeException), e.GetType());
+ AssertEquals("#E07", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E08", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // Even though Indexer is an object, really it's a string
+ object o = c[typeof(int)];
+ }
+ catch (Exception e) {
+ AssertEquals("#E09", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E10", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // can't specify both Before and After
+ c.Add("Kickball", "Kick", "Volley", "Foot");
+ }
+ catch (Exception e) {
+ AssertEquals("#E11", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E12", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // Key "Foot" already exists
+ c.Add("Kickball", "Foot", null, null);
+ }
+ catch (Exception e) {
+ AssertEquals("#E13", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E14", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // Even though Before is object, it's really a string
+ c.Add("Dodgeball", "Dodge", typeof(int), null);
+ }
+ catch (Exception e) {
+ AssertEquals("#E15", typeof(InvalidCastException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E16", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // Even though After is object, it's really a string
+ c.Add("Wallyball", "Wally", null, typeof(int));
+ }
+ catch (Exception e) {
+ AssertEquals("#E17", typeof(InvalidCastException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E18", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // have to pass a legitimate value to remove
+ c.Remove(null);
+ }
+ catch (Exception e) {
+ AssertEquals("#E19", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E20", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // no Key "Golf" exists
+ c.Remove("Golf");
+ }
+ catch (Exception e) {
+ AssertEquals("#E21", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E22", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ // no Index 10 exists
+ c.Remove(10);
+ }
+ catch (Exception e) {
+ AssertEquals("#E23", typeof(IndexOutOfRangeException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E24", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ IEnumerator e = c.GetEnumerator();
+
+ // Must MoveNext before Current
+ object item = e.Current;
+ }
+ catch (Exception e) {
+ // FIXME
+ // On-line help says InvalidOperationException here,
+ // but MS throws IndexOutOfRangeException
+ // AssertEquals("#E25", typeof(InvalidOperationException), e.GetType());
+ AssertEquals("#E25", typeof(IndexOutOfRangeException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#E26", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ IEnumerator e = c.GetEnumerator();
+ e.MoveNext();
+
+ c.Add("Paintball", "Paint", null, null);
+
+ // Can't MoveNext if Collection has been modified
+ e.MoveNext();
+ }
+ catch (Exception e) {
+ // FIXME
+ // On-line help says this should throw an error. MS doesn't.
+ AssertEquals("#E27", typeof(InvalidOperationException), e.GetType());
+ caughtException = true;
+ }
+
+ // FIXME
+ // What to do about this? MS doesn't throw an error
+ // AssertEquals("#E28", true, caughtException);
+ AssertEquals("#E28", false, caughtException);
+
+ caughtException = false;
+
+ try {
+ IEnumerator e = c.GetEnumerator();
+ e.MoveNext();
+
+ c.Add("Racketball", "Racket", null, null);
+
+ // Can't Reset if Collection has been modified
+ e.Reset();
+ }
+ catch (Exception e) {
+ // FIXME
+ // On-line help says this should throw an error. MS doesn't.
+ AssertEquals("#E29", typeof(InvalidOperationException), e.GetType());
+ caughtException = true;
+ }
+
+ // FIXME
+ // What to do about this? MS doesn't throw an error
+ // AssertEquals("#E30", true, caughtException);
+ AssertEquals("#E30", false, caughtException);
+
+ caughtException = false;
+ }
+ }
+}
diff --git a/mcs/class/Microsoft.VisualBasic/Test/ConversionTest.cs b/mcs/class/Microsoft.VisualBasic/Test/ConversionTest.cs
new file mode 100644
index 00000000000..991e6e82f61
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/ConversionTest.cs
@@ -0,0 +1,674 @@
+// Collection.cs - NUnit Test Cases for Microsoft.VisualBasic.Collection
+//
+// Author:
+// Chris J. Breisch (cjbreisch@altavista.net)
+//
+// (C) Chris J. Breisch
+//
+
+using NUnit.Framework;
+using System;
+using Microsoft.VisualBasic;
+
+namespace MonoTests.Microsoft.VisualBasic
+{
+
+ public class ConversionTest : TestCase
+ {
+
+ public ConversionTest() : base ("Microsoft.VisualBasic.Conversion") {}
+ public ConversionTest(string name) : base(name) {}
+
+ protected override void SetUp() {}
+ protected override void TearDown() {}
+
+ public static ITest Suite {
+ get {
+ return new TestSuite(typeof(ConversionTest));
+ }
+ }
+
+ public void TestErrorToStringEmpty() {
+ // FIXME : Do something here, but write the ErrorToString code first :-)
+ }
+
+ public void TestErrorToStringNumber() {
+ // FIXME : Do something here, but write the ErrorToString code first :-)
+ }
+
+ // Test the Fix function
+ public void TestFix() {
+ System.Single Sng;
+ System.Double Dbl;
+ System.Decimal Dec;
+ System.String S;
+ System.Object O;
+
+ AssertEquals("#F01", System.Int16.MaxValue, Conversion.Fix(System.Int16.MaxValue));
+ AssertEquals("#F02", System.Int16.MinValue, Conversion.Fix(System.Int16.MinValue));
+ AssertEquals("#F03", System.Int32.MaxValue, Conversion.Fix(System.Int32.MaxValue));
+ AssertEquals("#F04", System.Int32.MinValue, Conversion.Fix(System.Int32.MinValue));
+ AssertEquals("#F05", System.Int64.MaxValue, Conversion.Fix(System.Int64.MaxValue));
+ AssertEquals("#F06", System.Int64.MinValue, Conversion.Fix(System.Int64.MinValue));
+ AssertEquals("#F07", (System.Single)Math.Floor(System.Single.MaxValue), Conversion.Fix(System.Single.MaxValue));
+ AssertEquals("#F08", -1 * (System.Single)Math.Floor(-1 * System.Single.MinValue), Conversion.Fix(System.Single.MinValue));
+ AssertEquals("#F09", Math.Floor(System.Double.MaxValue), Conversion.Fix(System.Double.MaxValue));
+ AssertEquals("#F10", -1 * Math.Floor(-1 * System.Double.MinValue), Conversion.Fix(System.Double.MinValue));
+ AssertEquals("#F11", Decimal.Floor(System.Decimal.MaxValue), Conversion.Fix(System.Decimal.MaxValue));
+ AssertEquals("#F12", -1 * Decimal.Floor(-1 * System.Decimal.MinValue), Conversion.Fix(System.Decimal.MinValue));
+
+ Sng = 99.1F;
+
+ AssertEquals("#F13", 99F, Conversion.Fix(Sng));
+
+ Sng = 99.6F;
+
+ AssertEquals("#F14", 99F, Conversion.Fix(Sng));
+
+ Sng = -99.1F;
+
+ AssertEquals("#F15", -99F, Conversion.Fix(Sng));
+
+ Sng = -99.6F;
+
+ AssertEquals("#F16", -99F, Conversion.Fix(Sng));
+
+ Dbl = 99.1;
+
+ AssertEquals("#F17", 99D, Conversion.Fix(Dbl));
+
+ Dbl = 99.6;
+
+ AssertEquals("#F18", 99D, Conversion.Fix(Dbl));
+
+ Dbl = -99.1;
+
+ AssertEquals("#F19", -99D, Conversion.Fix(Dbl));
+
+ Dbl = -99.6;
+
+ AssertEquals("#F20", -99D, Conversion.Fix(Dbl));
+
+ Dec = 99.1M;
+
+ AssertEquals("#F21", 99M, Conversion.Fix(Dec));
+
+ Dec = 99.6M;
+
+ AssertEquals("#F22", 99M, Conversion.Fix(Dec));
+
+ Dec = -99.1M;
+
+ AssertEquals("#F23", -99M, Conversion.Fix(Dec));
+
+ Dec = -99.6M;
+
+ AssertEquals("#F24", -99M, Conversion.Fix(Dec));
+
+ Dbl = 99.1;
+ S = Dbl.ToString();
+
+ AssertEquals("#F25", 99D, Conversion.Fix(S));
+
+ Dbl = 99.6;
+ S = Dbl.ToString();
+
+ AssertEquals("#F26", 99D, Conversion.Fix(S));
+
+ Dbl = -99.1;
+ S = Dbl.ToString();
+
+ AssertEquals("#F27", -99D, Conversion.Fix(S));
+
+ Dbl = -99.6;
+ S = Dbl.ToString();
+
+ AssertEquals("#F28", -99D, Conversion.Fix(S));
+
+ Dbl = 99.1;
+ O = Dbl;
+
+ AssertEquals("#F29", 99D, Conversion.Fix(O));
+
+ Sng = 99.6F;
+ O = Sng;
+
+ AssertEquals("#F30", (System.Object)99F, Conversion.Fix(O));
+
+ Dbl = -99.1;
+ O = Dbl;
+
+ AssertEquals("#F31", -99D, Conversion.Fix(O));
+
+ Dec = -99.6M;
+ O = Dec;
+
+ AssertEquals("#F32", (System.Object)(-99M), Conversion.Fix(O));
+
+ O = typeof(int);
+
+ // test for Exceptions
+ bool caughtException = false;
+ try {
+ Conversion.Fix(O);
+ }
+ catch (Exception e) {
+ AssertEquals("#F33", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#F34", true, caughtException);
+
+ caughtException = false;
+ try {
+ Conversion.Fix(null);
+ }
+ catch (Exception e) {
+ AssertEquals("#F35", typeof(ArgumentNullException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#F36", true, caughtException);
+
+ }
+
+ // Test the Int function
+ public void TestInt() {
+ System.Single Sng;
+ System.Double Dbl;
+ System.Decimal Dec;
+ System.String S;
+ System.Object O;
+
+ AssertEquals("#I01", System.Int16.MaxValue, Conversion.Int(System.Int16.MaxValue));
+ AssertEquals("#I02", System.Int16.MinValue, Conversion.Int(System.Int16.MinValue));
+ AssertEquals("#I03", System.Int32.MaxValue, Conversion.Int(System.Int32.MaxValue));
+ AssertEquals("#I04", System.Int32.MinValue, Conversion.Int(System.Int32.MinValue));
+ AssertEquals("#I05", System.Int64.MaxValue, Conversion.Int(System.Int64.MaxValue));
+ AssertEquals("#I06", System.Int64.MinValue, Conversion.Int(System.Int64.MinValue));
+ AssertEquals("#I07", (System.Single)Math.Floor(System.Single.MaxValue), Conversion.Int(System.Single.MaxValue));
+ AssertEquals("#I08", (System.Single)Math.Floor(System.Single.MinValue), Conversion.Int(System.Single.MinValue));
+ AssertEquals("#I09", Math.Floor(System.Double.MaxValue), Conversion.Int(System.Double.MaxValue));
+ AssertEquals("#I10", Math.Floor(System.Double.MinValue), Conversion.Int(System.Double.MinValue));
+ AssertEquals("#I11", Decimal.Floor(System.Decimal.MaxValue), Conversion.Int(System.Decimal.MaxValue));
+ AssertEquals("#I12", Decimal.Floor(System.Decimal.MinValue), Conversion.Int(System.Decimal.MinValue));
+
+ Sng = 99.1F;
+
+ AssertEquals("#I13", 99F, Conversion.Int(Sng));
+
+ Sng = 99.6F;
+
+ AssertEquals("#I14", 99F, Conversion.Int(Sng));
+
+ Sng = -99.1F;
+
+ AssertEquals("#I15", -100F, Conversion.Int(Sng));
+
+ Sng = -99.6F;
+
+ AssertEquals("#I16", -100F, Conversion.Int(Sng));
+
+ Dbl = 99.1;
+
+ AssertEquals("#I17", 99D, Conversion.Int(Dbl));
+
+ Dbl = 99.6;
+
+ AssertEquals("#I18", 99D, Conversion.Int(Dbl));
+
+ Dbl = -99.1;
+
+ AssertEquals("#I19", -100D, Conversion.Int(Dbl));
+
+ Dbl = -99.6;
+
+ AssertEquals("#I20", -100D, Conversion.Int(Dbl));
+
+ Dec = 99.1M;
+
+ AssertEquals("#I21", 99M, Conversion.Int(Dec));
+
+ Dec = 99.6M;
+
+ AssertEquals("#I22", 99M, Conversion.Int(Dec));
+
+ Dec = -99.1M;
+
+ AssertEquals("#I23", -100M, Conversion.Int(Dec));
+
+ Dec = -99.6M;
+
+ AssertEquals("#I24", -100M, Conversion.Int(Dec));
+
+ Dbl = 99.1;
+ S = Dbl.ToString();
+
+ AssertEquals("#I25", 99D, Conversion.Int(S));
+
+ Dbl = 99.6;
+ S = Dbl.ToString();
+
+ AssertEquals("#I26", 99D, Conversion.Int(S));
+
+ Dbl = -99.1;
+ S = Dbl.ToString();
+
+ AssertEquals("#I27", -100D, Conversion.Int(S));
+
+ Dbl = -99.6;
+ S = Dbl.ToString();
+
+ AssertEquals("#I28", -100D, Conversion.Int(S));
+
+ Dbl = 99.1;
+ O = Dbl;
+
+ AssertEquals("#I29", 99D, Conversion.Int(O));
+
+ Sng = 99.6F;
+ O = Sng;
+
+ AssertEquals("#I30", 99F, Conversion.Int(O));
+
+ Dbl = -99.1;
+ O = Dbl;
+
+ AssertEquals("#I31", -100D, Conversion.Int(O));
+
+ Dec = -99.6M;
+ O = Dec;
+
+ AssertEquals("#I32", -100M, Conversion.Int(O));
+
+ // test the exceptions it's supposed to throw
+
+ O = typeof(int);
+ bool caughtException = false;
+
+ try {
+ Conversion.Fix(O);
+ }
+ catch (Exception e) {
+ AssertEquals("#I33", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#I34", true, caughtException);
+
+ caughtException = false;
+ try {
+ Conversion.Int(null);
+ }
+ catch (Exception e) {
+ AssertEquals("#I35", typeof(ArgumentNullException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#I36", true, caughtException);
+
+
+ }
+
+ // test the Hex function
+ public void TestHex() {
+ AssertEquals("#H01", "FF", Conversion.Hex(System.Byte.MaxValue));
+ AssertEquals("#H02", "0", Conversion.Hex(System.Byte.MinValue));
+ AssertEquals("#H03", "7FFF", Conversion.Hex(System.Int16.MaxValue));
+ AssertEquals("#H04", "8000", Conversion.Hex(System.Int16.MinValue));
+ AssertEquals("#H05", "7FFFFFFF", Conversion.Hex(System.Int32.MaxValue));
+ AssertEquals("#H06", "80000000", Conversion.Hex(System.Int32.MinValue));
+ AssertEquals("#H07", "7FFFFFFFFFFFFFFF", Conversion.Hex(System.Int64.MaxValue));
+ AssertEquals("#H08", "8000000000000000", Conversion.Hex(System.Int64.MinValue));
+
+ System.Byte UI8;
+ System.Int16 I16;
+ System.Int32 I32;
+ System.Int64 I64;
+ System.Object O;
+ System.String S;
+
+ UI8 = 15;
+ AssertEquals("#H09", "F", Conversion.Hex(UI8));
+
+ I16 = System.Byte.MaxValue;
+ AssertEquals("#H10", "FF", Conversion.Hex(I16));
+
+ I16 = (System.Int16)((I16 + 1) * -1);
+ AssertEquals("#H11", "FF00", Conversion.Hex(I16));
+
+ I16 = -2;
+ AssertEquals("#H12", "FFFE", Conversion.Hex(I16));
+
+ I32 = System.UInt16.MaxValue;
+ AssertEquals("#H13", "FFFF", Conversion.Hex(I32));
+
+ I32 = (I32 + 1) * -1;
+ AssertEquals("#H14", "FFFF0000", Conversion.Hex(I32));
+
+ I32 = -2;
+ AssertEquals("#H15", "FFFFFFFE", Conversion.Hex(I32));
+
+ I64 = System.UInt32.MaxValue;
+ AssertEquals("#H16", "FFFFFFFF", Conversion.Hex(I64));
+
+ I64 = (I64 + 1) * -1;
+ AssertEquals("#H17", "FFFFFFFF00000000", Conversion.Hex(I64));
+
+ I64 = -2;
+ AssertEquals("#H18", "FFFFFFFFFFFFFFFE", Conversion.Hex(I64));
+
+ I16 = System.Byte.MaxValue;
+ S = I16.ToString();
+ AssertEquals("#H19", "FF", Conversion.Hex(S));
+
+ I16 = (System.Int16)((I16 + 1) * -1);
+ S = I16.ToString();
+ AssertEquals("#H20", "FFFFFF00", Conversion.Hex(S));
+
+ I16 = -1;
+ S = I16.ToString();
+ AssertEquals("#H21", "FFFFFFFF", Conversion.Hex(S));
+
+ I32 = System.UInt16.MaxValue;
+ S = I32.ToString();
+ AssertEquals("#H22", "FFFF", Conversion.Hex(S));
+
+ I32 = (I32 + 1) * -1;
+ S = I32.ToString();
+ AssertEquals("#H23", "FFFF0000", Conversion.Hex(S));
+
+ I32 = -2;
+ S = I32.ToString();
+ AssertEquals("#H24", "FFFFFFFE", Conversion.Hex(S));
+
+ I64 = System.UInt32.MaxValue;
+ S = I64.ToString();
+ AssertEquals("#H25", "FFFFFFFF", Conversion.Hex(S));
+
+ I64 = (I64 + 1) * -1;
+ S = I64.ToString();
+ AssertEquals("#H26", "FFFFFFFF00000000", Conversion.Hex(S));
+
+ UI8 = System.Byte.MaxValue;
+ O = UI8;
+ AssertEquals("#H27", "FF", Conversion.Hex(O));
+
+ I16 = System.Byte.MaxValue;
+ O = I16;
+ AssertEquals("#H28", "FF", Conversion.Hex(O));
+
+ I16 = (System.Int16)((I16 + 1) * -1);
+ O = I16;
+ AssertEquals("#H29", "FF00", Conversion.Hex(O));
+
+ I16 = -2;
+ O = I16;
+ AssertEquals("#H30", "FFFE", Conversion.Hex(O));
+
+ I32 = System.UInt16.MaxValue;
+ O = I32;
+ AssertEquals("#H31", "FFFF", Conversion.Hex(O));
+
+ I32 = (I32 + 1) * -1;
+ O = I32;
+ AssertEquals("#H32", "FFFF0000", Conversion.Hex(O));
+
+ I32 = -2;
+ O = I32;
+ AssertEquals("#H33", "FFFFFFFE", Conversion.Hex(O));
+
+ I64 = System.UInt32.MaxValue;
+ O = I64;
+ AssertEquals("#H34", "FFFFFFFF", Conversion.Hex(O));
+
+ I64 = (I64 + 1) * -1;
+ O = I64;
+ AssertEquals("#H35", "FFFFFFFF00000000", Conversion.Hex(O));
+
+ I64 = -2;
+ O = I64;
+ // FIXME : MS doesn't pass this test
+ //AssertEquals("#H35", "FFFFFFFFFFFFFFFE", Conversion.Hex(O));
+
+ O = typeof(int);
+
+ bool caughtException = false;
+ try {
+ Conversion.Hex(O);
+ }
+ catch (Exception e) {
+ AssertEquals("#H36", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#H37", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ Conversion.Hex(null);
+ }
+ catch (Exception e) {
+ AssertEquals("#H38", typeof(ArgumentNullException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#H39", true, caughtException);
+ }
+
+ // test the Oct function
+ public void TestOct() {
+ AssertEquals("#O01", "377", Conversion.Oct(System.Byte.MaxValue));
+ AssertEquals("#O02", "0", Conversion.Oct(System.Byte.MinValue));
+ AssertEquals("#O03", "77777", Conversion.Oct(System.Int16.MaxValue));
+ AssertEquals("#O04", "100000", Conversion.Oct(System.Int16.MinValue));
+ AssertEquals("#O05", "17777777777", Conversion.Oct(System.Int32.MaxValue));
+ AssertEquals("#O06", "20000000000", Conversion.Oct(System.Int32.MinValue));
+ AssertEquals("#O07", "777777777777777777777", Conversion.Oct(System.Int64.MaxValue));
+ //AssertEquals("#O08", "1000000000000000000000", Conversion.Oct(System.Int64.MinValue));
+
+ System.Byte UI8;
+ System.Int16 I16;
+ System.Int32 I32;
+ System.Int64 I64;
+ System.Object O;
+ System.String S;
+
+ UI8 = 15;
+ AssertEquals("#O09", "17", Conversion.Oct(UI8));
+
+ I16 = System.Byte.MaxValue;
+ AssertEquals("#O10", "377", Conversion.Oct(I16));
+
+ I16 = (System.Int16)((I16 + 1) * -1);
+ AssertEquals("#O11", "177400", Conversion.Oct(I16));
+
+ I16 = -2;
+ AssertEquals("#O12", "177776", Conversion.Oct(I16));
+
+ I32 = System.UInt16.MaxValue;
+ AssertEquals("#O13", "177777", Conversion.Oct(I32));
+
+ I32 = (I32 + 1) * -1;
+ AssertEquals("#O14", "37777600000", Conversion.Oct(I32));
+
+ I32 = -2;
+ AssertEquals("#O15", "37777777776", Conversion.Oct(I32));
+
+ I64 = System.UInt32.MaxValue;
+ AssertEquals("#O16", "37777777777", Conversion.Oct(I64));
+
+ I64 = (I64 + 1) * -1;
+ AssertEquals("#O17", "1777777777740000000000", Conversion.Oct(I64));
+
+ I64 = -2;
+ AssertEquals("#O18", "1777777777777777777776", Conversion.Oct(I64));
+
+ I16 = System.Byte.MaxValue;
+ S = I16.ToString();
+ AssertEquals("#O19", "377", Conversion.Oct(S));
+
+ I16 = (System.Int16)((I16 + 1) * -1);
+ S = I16.ToString();
+ AssertEquals("#O20", "37777777400", Conversion.Oct(S));
+
+ I16 = -2;
+ S = I16.ToString();
+ AssertEquals("#O21", "37777777776", Conversion.Oct(S));
+
+ I32 = System.UInt16.MaxValue;
+ S = I32.ToString();
+ AssertEquals("#O22", "177777", Conversion.Oct(S));
+
+ I32 = (I32 + 1) * -1;
+ S = I32.ToString();
+ AssertEquals("#O23", "37777600000", Conversion.Oct(S));
+
+ I32 = -2;
+ S = I32.ToString();
+ AssertEquals("#O24", "37777777776", Conversion.Oct(S));
+
+ I64 = System.UInt32.MaxValue;
+ S = I64.ToString();
+ AssertEquals("#O25", "37777777777", Conversion.Oct(S));
+
+ I64 = (I64 + 1) * -1;
+ S = I64.ToString();
+ AssertEquals("#O26", "1777777777740000000000", Conversion.Oct(S));
+
+ UI8 = System.Byte.MaxValue;
+ O = UI8;
+ AssertEquals("#O27", "377", Conversion.Oct(O));
+
+ I16 = System.Byte.MaxValue;
+ O = I16;
+ AssertEquals("#O28", "377", Conversion.Oct(O));
+
+ I16 = (System.Int16)((I16 + 1) * -1);
+ O = I16;
+ AssertEquals("#O29", "177400", Conversion.Oct(O));
+
+ I16 = -2;
+ O = I16;
+ AssertEquals("#O29", "177776", Conversion.Oct(O));
+
+ I32 = System.UInt16.MaxValue;
+ O = I32;
+ AssertEquals("#O30", "177777", Conversion.Oct(O));
+
+ I32 = (I32 + 1) * -1;
+ O = I32;
+ AssertEquals("#O31", "37777600000", Conversion.Oct(O));
+
+ I32 = -2;
+ O = I32;
+ AssertEquals("#O32", "37777777776", Conversion.Oct(O));
+
+ I64 = System.UInt32.MaxValue;
+ O = I64;
+ AssertEquals("#O33", "37777777777", Conversion.Oct(O));
+
+ I64 = (I64 + 1) * -1;
+ O = I64;
+ AssertEquals("#O34", "1777777777740000000000", Conversion.Oct(O));
+
+ I64 = -2;
+ O = I64;
+
+ // FIXME: MS doesn't pass this test
+ // AssertEquals("#O35", "1777777777777777777776", Conversion.Oct(O));
+
+ O = typeof(int);
+
+ bool caughtException = false;
+ try {
+ Conversion.Oct(O);
+ }
+ catch (Exception e) {
+ AssertEquals("#O36", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#O37", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ Conversion.Oct(null);
+ }
+ catch (Exception e) {
+ AssertEquals("#O38", typeof(ArgumentNullException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#O39", true, caughtException);
+ }
+
+ // test the Str function
+ public void TestStr() {
+ AssertEquals("#S01", "-1", Conversion.Str(-1));
+ AssertEquals("#S02", " 1", Conversion.Str(1));
+
+ bool caughtException = false;
+ Object O = typeof(int);
+
+ try {
+ Conversion.Str(O);
+ }
+ catch (Exception e) {
+ AssertEquals("#S03", typeof(InvalidCastException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#S04", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ Conversion.Str(null);
+ }
+ catch (Exception e) {
+ AssertEquals("#S05", typeof(ArgumentNullException), e.GetType());
+ caughtException = true;
+ }
+ }
+
+ // Test the Val function
+ public void TestVal() {
+ AssertEquals("#V01", 4, Conversion.Val('4'));
+ AssertEquals("#V02", -3542.76, Conversion.Val(" - 3 5 .4 2 7 6E+ 0 0 2 "));
+ AssertEquals("#V03", 255D, Conversion.Val("&HFF"));
+ AssertEquals("#V04", 255D, Conversion.Val("&o377"));
+
+ System.Object O = " - 3 5 .4 7 6E+ 0 0 3";
+
+ AssertEquals("#V05", -35476D, Conversion.Val(O));
+
+ bool caughtException;
+
+ caughtException = false;
+
+ try {
+ Conversion.Val("3E+9999999");
+ }
+ catch (Exception e) {
+ AssertEquals("#V06", typeof(OverflowException), e.GetType());
+ caughtException = true;
+ }
+
+ AssertEquals("#V07", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ Conversion.Val(typeof(int));
+ }
+ catch (Exception e) {
+ AssertEquals("#V08", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+ AssertEquals("#V09", true, caughtException);
+ }
+ }
+}
diff --git a/mcs/class/Microsoft.VisualBasic/Test/DateAndTimeTest.cs b/mcs/class/Microsoft.VisualBasic/Test/DateAndTimeTest.cs
new file mode 100644
index 00000000000..0c8f38436f7
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/DateAndTimeTest.cs
@@ -0,0 +1,388 @@
+// Collection.cs - NUnit Test Cases for Microsoft.VisualBasic.Collection
+//
+// Author:
+// Chris J. Breisch (cjbreisch@altavista.net)
+//
+// (C) Chris J. Breisch
+//
+
+using NUnit.Framework;
+using System;
+using System.Threading;
+using System.Globalization;
+using Microsoft.VisualBasic;
+
+namespace MonoTests.Microsoft.VisualBasic
+{
+
+ public class DateAndTimeTest : TestCase {
+
+ private CultureInfo oldcult;
+
+ public DateAndTimeTest() : base ("Microsoft.VisualBasic.DateAndTime") {}
+ public DateAndTimeTest(string name) : base(name) {}
+
+ protected override void SetUp()
+ {
+ // the current culture determines the result of formatting
+ oldcult = Thread.CurrentThread.CurrentCulture;
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("");
+ }
+
+ protected override void TearDown ()
+ {
+ Thread.CurrentThread.CurrentCulture = oldcult;
+ }
+
+ public static ITest Suite {
+ get {
+ return new TestSuite(typeof(DateAndTimeTest));
+ }
+ }
+
+ public void TestDateString() {
+ string s = DateAndTime.DateString;
+ DateTime dtNow = DateTime.Today;
+ AssertEquals("#DS01", dtNow.ToShortDateString(), DateTime.Parse(s).ToShortDateString());
+
+ // TODO: Add a test for setting the date string too
+ }
+
+ public void TestToday() {
+ AssertEquals("#TO01", DateTime.Today, DateAndTime.Today);
+
+ // TODO: Add a test for setting Today
+ }
+
+ public void TestTimer() {
+ double secTimer = DateAndTime.Timer;
+ DateTime dtNow = DateTime.Now;
+ double secNow = dtNow.Hour * 3600 + dtNow.Minute * 60 + dtNow.Second + (dtNow.Millisecond + 1) / 1000D;
+ double secTimer2 = DateAndTime.Timer + .001;
+
+ // waste a little time
+ for (int i = 0; i < int.MaxValue; i++);
+
+ // get another timer
+ double secTimer3 = DateAndTime.Timer;
+
+ // should be same time within a reasonable tolerance
+ Assert("#TI01", secNow >= secTimer);
+ Assert("#TI02: SecTimer2=" + secTimer2 + " secNow=" + secNow, secTimer2 >= secNow);
+
+ // third timer should be greater than the first
+ Assert("#TI03", secTimer3 > secTimer);
+ }
+
+ public void TestNow() {
+ DateTime dtNow = DateTime.Now;
+ DateTime dtTest = DateAndTime.Now;
+ DateTime dtNow2 = DateTime.Now;
+
+ Assert("#N01", dtTest >= dtNow);
+ Assert("#N02", dtNow2 >= dtTest);
+ }
+
+ public void TestTimeOfDay() {
+ DateTime dtNow = DateTime.Now;
+ TimeSpan tsNow = new TimeSpan(dtNow.Hour, dtNow.Minute, dtNow.Second);
+ DateTime dtTest = DateAndTime.TimeOfDay;
+ TimeSpan tsTest = new TimeSpan(dtTest.Hour, dtTest.Minute, dtTest.Second);
+ DateTime dtNow2 = DateTime.Now;
+ TimeSpan tsNow2 = new TimeSpan(dtNow2.Hour, dtNow2.Minute, dtNow2.Second);
+
+ Assert("#TOD01", tsTest.Ticks >= tsNow.Ticks);
+ Assert("#TOD02", tsNow2.Ticks >= tsTest.Ticks);
+
+ // TODO: add a test case for setting time of day
+ }
+
+ public void TestTimeString() {
+ DateTime dtNow = DateTime.Now;
+ TimeSpan tsNow = new TimeSpan(dtNow.Hour, dtNow.Minute, dtNow.Second);
+ string s = DateAndTime.TimeString;
+ DateTime dtTest = DateTime.Parse(s);
+ TimeSpan tsTest = new TimeSpan(dtTest.Hour, dtTest.Minute, dtTest.Second);
+ DateTime dtNow2 = DateTime.Now;
+ TimeSpan tsNow2 = new TimeSpan(dtNow2.Hour, dtNow2.Minute, dtNow2.Second);
+
+ Assert("#TS01", tsTest.Ticks >= tsNow.Ticks);
+ Assert("#TS02", tsNow2.Ticks >= tsTest.Ticks);
+
+ // TODO: add a test case for setting TimeString
+ }
+
+ public void TestDateAdd() {
+ DateTime dtNow = DateTime.Now;
+
+ AssertEquals("#DA01", dtNow.AddYears(1), DateAndTime.DateAdd(DateInterval.Year, 1, dtNow));
+ AssertEquals("#DA02", dtNow.AddYears(-1), DateAndTime.DateAdd("yyyy", -1, dtNow));
+
+
+ bool caughtException = false;
+
+ try {
+ DateAndTime.DateAdd("foo", 1, dtNow);
+ }
+ catch (Exception e) {
+ AssertEquals("#DA03", e.GetType(), typeof(ArgumentException));
+ caughtException = true;
+ }
+
+ AssertEquals("#DA04", caughtException, true);
+
+ AssertEquals("#DA05", dtNow.AddMonths(6), DateAndTime.DateAdd(DateInterval.Quarter, 2, dtNow));
+ AssertEquals("#DA06", dtNow.AddMonths(-6), DateAndTime.DateAdd("q", -2, dtNow));
+
+ AssertEquals("#DA07", dtNow.AddMonths(3), DateAndTime.DateAdd(DateInterval.Month, 3, dtNow));
+ AssertEquals("#DA08", dtNow.AddMonths(-3), DateAndTime.DateAdd("m", -3, dtNow));
+
+ AssertEquals("#DA09", dtNow.AddDays(28), DateAndTime.DateAdd(DateInterval.WeekOfYear, 4, dtNow));
+ AssertEquals("#DA10", dtNow.AddDays(-28), DateAndTime.DateAdd("ww", -4, dtNow));
+
+ AssertEquals("#DA11", dtNow.AddDays(5), DateAndTime.DateAdd(DateInterval.Weekday, 5, dtNow));
+ AssertEquals("#DA12", dtNow.AddDays(-5), DateAndTime.DateAdd("w", -5, dtNow));
+
+ AssertEquals("#DA13", dtNow.AddDays(6), DateAndTime.DateAdd(DateInterval.DayOfYear, 6, dtNow));
+ AssertEquals("#DA14", dtNow.AddDays(-6), DateAndTime.DateAdd("y", -6, dtNow));
+
+ AssertEquals("#DA15", dtNow.AddDays(7), DateAndTime.DateAdd(DateInterval.Day, 7, dtNow));
+ AssertEquals("#DA16", dtNow.AddDays(-7), DateAndTime.DateAdd("d", -7, dtNow));
+
+ AssertEquals("#DA17", dtNow.AddHours(8), DateAndTime.DateAdd(DateInterval.Hour, 8, dtNow));
+ AssertEquals("#DA18", dtNow.AddHours(-8), DateAndTime.DateAdd(DateInterval.Hour, -8, dtNow));
+
+ AssertEquals("#DA19", dtNow.AddMinutes(9), DateAndTime.DateAdd(DateInterval.Minute, 9, dtNow));
+ AssertEquals("#DA20", dtNow.AddMinutes(-9), DateAndTime.DateAdd("n", -9, dtNow));
+
+ AssertEquals("#DA21", dtNow.AddSeconds(10), DateAndTime.DateAdd(DateInterval.Second, 10, dtNow));
+ AssertEquals("#DA22", dtNow.AddSeconds(-10), DateAndTime.DateAdd("s", -10, dtNow));
+
+ caughtException = false;
+
+ try {
+ DateAndTime.DateAdd(DateInterval.Year, int.MinValue, dtNow);
+ }
+ catch (Exception e) {
+ caughtException = true;
+ AssertEquals("#DA23", e.GetType(), typeof(Exception));
+ }
+
+ // AssertEquals("#DA24", caughtException, true);
+ }
+
+ public void TestDateDiff () {
+ DateTime dtNow = DateTime.Now;
+ DateTime dtOld = dtNow.AddYears(-1);
+
+ // TODO: Test this better
+ long diff = DateAndTime.DateDiff(DateInterval.Year, dtOld, dtNow, FirstDayOfWeek.System, FirstWeekOfYear.System);
+
+ AssertEquals("#DD01", dtNow, dtOld.AddYears((int)diff));
+
+ DateTime dtJan1 = new DateTime(2002, 1, 1);
+ DateTime dtDec31 = new DateTime(2001, 12, 31);
+
+ diff = DateAndTime.DateDiff(DateInterval.Year, dtDec31, dtJan1, FirstDayOfWeek.System, FirstWeekOfYear.System);
+
+ AssertEquals("#DD02", 1L, diff);
+
+ diff = DateAndTime.DateDiff(DateInterval.Quarter, dtDec31, dtJan1, FirstDayOfWeek.System, FirstWeekOfYear.System);
+
+ AssertEquals("#DD03", 1L, diff);
+
+ diff = DateAndTime.DateDiff(DateInterval.Month, dtDec31, dtJan1, FirstDayOfWeek.System, FirstWeekOfYear.System);
+
+ AssertEquals("#DD04", 1L, diff);
+
+ DateTime dtJan4 = new DateTime(2001, 1, 4); // This is a Thursday
+ DateTime dtJan9 = new DateTime(2001, 1, 9); // This is the next Tuesday
+
+
+ long WD = DateAndTime.DateDiff(DateInterval.Weekday, dtJan4, dtJan9, FirstDayOfWeek.System, FirstWeekOfYear.System);
+
+ AssertEquals ("#DD05", 0L, WD);
+
+ long WY = DateAndTime.DateDiff(DateInterval.WeekOfYear, dtJan4, dtJan9, FirstDayOfWeek.System, FirstWeekOfYear.System);
+
+ AssertEquals ("#DD06", 1L, WY);
+ }
+
+ public void TestDatePart () {
+ DateTime dtJan4 = new DateTime(2001, 1, 4);
+
+ // TODO: Test this better
+
+ AssertEquals("#DP01", 2001, DateAndTime.DatePart(DateInterval.Year, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ AssertEquals("#DP02", 1, DateAndTime.DatePart(DateInterval.Quarter, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ AssertEquals("#DP03", 1, DateAndTime.DatePart(DateInterval.Month, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ AssertEquals("#DP04", 1, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP05", 53, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.FirstFullWeek));
+ AssertEquals("#DP06", 1, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.Jan1));
+ AssertEquals("#DP07", 1, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ AssertEquals("#DP08", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Friday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP09", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Saturday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP10", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Sunday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP11", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP12", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Tuesday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP13", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Wednesday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP14", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Thursday, FirstWeekOfYear.FirstFourDays));
+ AssertEquals("#DP15", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.FirstFourDays));
+
+
+ }
+
+ public void TestDateSerial () {
+ DateTime dtJan4 = new DateTime(2001, 1, 4);
+ DateTime dtSerial = DateAndTime.DateSerial(2001, 1, 4);
+
+ AssertEquals("#DS01", dtJan4, dtSerial);
+ }
+
+ public void TestTimeSerial () {
+ bool caughtException = false;
+
+ try {
+ DateAndTime.TimeSerial(0, -1440, -1);
+ }
+ catch (Exception e) {
+ AssertEquals("#TS01", e.GetType(), typeof(ArgumentOutOfRangeException));
+ caughtException = true;
+ }
+ AssertEquals("#TS02", true, caughtException);
+
+ AssertEquals("#TS03", new DateTime(1, 1, 1, 1, 1, 1), DateAndTime.TimeSerial(1, 1, 1));
+
+ }
+
+ public void TestDateValue () {
+ try {
+ DateAndTime.DateValue("This is not a date.");
+ }
+ catch (FormatException) {
+ /* do nothing. this is what we expect */
+ }
+ catch (Exception e) {
+ Fail ("Unexpected exception:" + e);
+ }
+ AssertEquals("#DV03", new DateTime(1969, 2, 12), DateAndTime.DateValue("February 12, 1969"));
+ }
+
+ public void TestTimeValue () {
+ try {
+ DateAndTime.TimeValue("This is not a time.");
+ }
+ catch (FormatException) {
+ /* do nothing. this is what we expect */
+ }
+ catch (Exception e) {
+ Fail ("Unexpected exception:" + e);
+ }
+ AssertEquals("#TV03", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 16, 35, 17), DateAndTime.TimeValue("4:35:17 PM"));
+ }
+
+ public void TestYear () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#Y01", jan1.Year, DateAndTime.Year(jan1));
+ }
+
+ public void TestMonth () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#MO01", jan1.Month, DateAndTime.Month(jan1));
+ }
+
+ public void TestDay () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#D01", jan1.Day, DateAndTime.Day(jan1));
+ }
+
+ public void TestHour () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#H01", jan1.Hour, DateAndTime.Hour(jan1));
+ }
+
+ public void TestMinute () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#MI01", jan1.Minute, DateAndTime.Minute(jan1));
+ }
+
+ public void TestSecond () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#S01", jan1.Second, DateAndTime.Second(jan1));
+ }
+
+ public void TestWeekday () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#W01", (int)jan1.DayOfWeek + 1, DateAndTime.Weekday(jan1, FirstDayOfWeek.System));
+ }
+
+ public void TestMonthName () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#MN01", CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(jan1.Month),
+ DateAndTime.MonthName(jan1.Month, true));
+ AssertEquals("#MN02", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(jan1.Month),
+ DateAndTime.MonthName(jan1.Month, false));
+
+ bool caughtException = false;
+
+ try {
+ DateAndTime.MonthName(0, false);
+ }
+ catch (Exception e) {
+ AssertEquals("#MN03", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+ AssertEquals("#MN04", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ DateAndTime.MonthName(14, false);
+ }
+ catch (Exception e) {
+ AssertEquals("#MN05", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+ AssertEquals("#MN06", true, caughtException);
+
+ //AssertEquals("#MN07", "", DateAndTime.MonthName(13, false));
+ }
+
+ public void TestWeekdayName () {
+ DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
+ AssertEquals("#WN01", "Tue",
+ DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, true, FirstDayOfWeek.System));
+ AssertEquals("#WN02", "Tuesday",
+ DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, false, FirstDayOfWeek.System));
+
+ bool caughtException = false;
+
+ try {
+ DateAndTime.WeekdayName(0, false, FirstDayOfWeek.System);
+ }
+ catch (Exception e) {
+ AssertEquals("#WN03", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+ AssertEquals("#WN04", true, caughtException);
+
+ caughtException = false;
+
+ try {
+ DateAndTime.WeekdayName(8, false, FirstDayOfWeek.System);
+ }
+ catch (Exception e) {
+ AssertEquals("#WN05", typeof(ArgumentException), e.GetType());
+ caughtException = true;
+ }
+ AssertEquals("#WN06", true, caughtException);
+
+ AssertEquals("#WN07", "Tuesday", DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, false, FirstDayOfWeek.System));
+ }
+
+
+
+
+
+ }
+}
diff --git a/mcs/class/Microsoft.VisualBasic/Test/Microsoft.VisualBasic_test.build b/mcs/class/Microsoft.VisualBasic/Test/Microsoft.VisualBasic_test.build
new file mode 100644
index 00000000000..3e205b08b8f
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/Microsoft.VisualBasic_test.build
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<!-- NAnt build file for System.Data_test.dll -->
+<!-- Target build (default) builds tests -->
+<!-- Target test runs tests -->
+
+<project name="System.Data_test" default="build">
+ <property name="debug" value="false"/>
+ <property name="nunit_home" value="..\..\..\nunit"/>
+
+ <target name="build">
+ </target>
+
+ <target name="assemblies">
+ <csc target="library" output="Microsoft.VisualBasic_test.dll" debug="${debug}">
+ <arg value="/nowarn:1595"/>
+ <sources>
+ <includes name="**/*.cs"/>
+ <excludes name="TheTests.cs"/>
+ </sources>
+ <references basedir="..\..\..\nunit">
+ <includes name="NUnitCore.dll"/>
+ </references>
+ <arg value="/noconfig"/> <!-- don't reference ms assemblies -->
+ <!--<arg value="/lib:../../lib/"/>-->
+
+ <!-- cor compare dies with these currently -->
+ <!--<arg value="/nostdlib"/>--> <!-- don't reference mscorlib -->
+ <!--<arg value="/r:corlib.dll"/>-->
+ <arg value="/r:System.dll"/>
+ <arg value="/r:.\Microsoft.VisualBasic.dll"/>
+ </csc>
+
+<!--
+ <csc target="exe" output="RunTests.Microsoft.VisualBasic.exe" debug="${debug}">
+ <sources>
+ <includes name="**/*.cs"/>
+ <excludes name="AllTests.cs"/>
+ </sources>
+ <references basedir="..\..\..\nunit">
+ <includes name="NUnitBase.dll"/>
+ </references>
+ <arg value="/nowarn:1595"/>
+ <arg value="/noconfig"/>
+ <arg value="/r:..\..\lib\corlib.dll"/>
+ <arg value="/r:..\..\lib\System.dll"/>
+ <arg value="/r:..\..\lib\Microsoft.VisualBasic.dll"/>
+ </csc>
+
+-->
+ </target>
+
+ <target name="test" depends="assemblies">
+ <exec program="..\..\..\nunit\NUnitConsole" commandline="MonoTests.AllTests,Microsoft.VisualBasic_test.dll" failonerror="false"/>
+ </target>
+
+ <target name="clean">
+ <delete file="Microsoft.VisualBasic.dll" failonerror="false"/>
+ <delete file="Microsoft.VisualBasic_test.dll" failonerror="false"/>
+ <delete file="corlib.dll" failonerror="false"/>
+ <delete file="System.dll" failonerror="false"/>
+ </target>
+</project>