[Mono-devel-list] Upgrading of NUnit 1.x tests
Martin Willemoes Hansen
mwh at sysrq.dk
Tue Mar 11 06:19:59 EST 2003
Okay to commit?
Okay to remove AllTests.cs?
--
Martin Willemoes Hansen
--------------------------------------------------------
E-Mail mwh at sysrq.dk Website mwh.sysrq.dk
IRC MWH, freenode.net
--------------------------------------------------------
-------------- next part --------------
Index: makefile.gnu
===================================================================
RCS file: /cvs/public/mcs/class/Microsoft.VisualBasic/makefile.gnu,v
retrieving revision 1.2
diff -u -r1.2 makefile.gnu
--- makefile.gnu 14 Sep 2002 14:14:37 -0000 1.2
+++ makefile.gnu 11 Mar 2003 11:21:46 -0000
@@ -1,5 +1,6 @@
topdir = ../..
+TEST_DIR= Test
LIBRARY = $(topdir)/class/lib/Microsoft.VisualBasic.dll
LIB_LIST = list
Index: Test/CollectionTest.cs
===================================================================
RCS file: /cvs/public/mcs/class/Microsoft.VisualBasic/Test/CollectionTest.cs,v
retrieving revision 1.2
diff -u -r1.2 CollectionTest.cs
--- Test/CollectionTest.cs 22 Jun 2002 10:15:34 -0000 1.2
+++ Test/CollectionTest.cs 11 Mar 2003 11:21:46 -0000
@@ -13,35 +13,31 @@
namespace MonoTests.Microsoft.VisualBasic
{
-
- public class CollectionTest : TestCase
+ [TestFixture]
+ public class CollectionTest
{
-
- 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));
- }
- }
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
// Test Constructor
- public void TestNew ()
+ [Test]
+ public void New ()
{
Collection c;
c = new Collection();
- AssertNotNull("#N01", c);
- AssertEquals("#N02", 0, c.Count);
+ Assertion.AssertNotNull("#N01", c);
+ Assertion.AssertEquals("#N02", 0, c.Count);
}
// Test Add method with Key == null
- public void TestAddNoKey ()
+ [Test]
+ public void AddNoKey ()
{
Collection c;
@@ -51,15 +47,16 @@
c.Add(typeof(double), null, null, null);
c.Add(typeof(string), null, null, null);
- AssertEquals("#ANK01", 3, c.Count);
+ Assertion.AssertEquals("#ANK01", 3, c.Count);
// Collection class is 1-based
- AssertEquals("#ANK02", typeof(string), c[3]);
+ Assertion.AssertEquals("#ANK02", typeof(string), c[3]);
}
// Test Add method with Key specified
- public void TestAddKey ()
+ [Test]
+ public void AddKey ()
{
Collection c;
@@ -70,16 +67,17 @@
c.Add("Basketball", "Basket", null, null);
c.Add("Volleyball", "Volley", null, null);
- AssertEquals("#AK01", 4, c.Count);
+ Assertion.AssertEquals("#AK01", 4, c.Count);
// Collection class is 1-based
- AssertEquals("#AK02", "Baseball", c[1]);
- AssertEquals("#AK03", "Volleyball", c["Volley"]);
+ Assertion.AssertEquals("#AK02", "Baseball", c[1]);
+ Assertion.AssertEquals("#AK03", "Volleyball", c["Volley"]);
}
// Test Add method with Before specified and Key == null
- public void TestAddBeforeNoKey ()
+ [Test]
+ public void AddBeforeNoKey ()
{
Collection c;
@@ -90,17 +88,18 @@
c.Add(typeof(string), null, 2, null);
c.Add(typeof(object), null, 2, null);
- AssertEquals("#ABNK01", 4, c.Count);
+ Assertion.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]);
+ Assertion.AssertEquals("#ABNK02", typeof(int), c[4]);
+ Assertion.AssertEquals("#ABNK03", typeof(double), c[1]);
+ Assertion.AssertEquals("#ABNK04", typeof(object), c[2]);
}
// Test Add method with Before and Key
- public void TestAddBeforeKey ()
+ [Test]
+ public void AddBeforeKey ()
{
Collection c;
@@ -111,16 +110,17 @@
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"]);
+ Assertion.AssertEquals("#ABK01", 4, c.Count);
+ Assertion.AssertEquals("#ABK02", "Basketball", c[1]);
+ Assertion.AssertEquals("#ABK03", "Baseball", c[4]);
+ Assertion.AssertEquals("#ABK04", "Volleyball", c["Volley"]);
+ Assertion.AssertEquals("#ABK05", "Football", c["Foot"]);
}
// Test Add method with After specified and Key == null
- public void TestAddAfterNoKey ()
+ [Test]
+ public void AddAfterNoKey ()
{
Collection c;
@@ -131,17 +131,18 @@
c.Add(typeof(string), null, null, 1);
c.Add(typeof(object), null, null, 3);
- AssertEquals("#AANK01", 4, c.Count);
+ Assertion.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]);
+ Assertion.AssertEquals("#AANK02", typeof(object), c[4]);
+ Assertion.AssertEquals("#AANK03", typeof(int), c[1]);
+ Assertion.AssertEquals("#AANK04", typeof(string), c[2]);
}
// Test Add method with After and Key
- public void TestAddAfterKey ()
+ [Test]
+ public void AddAfterKey ()
{
Collection c;
@@ -152,17 +153,18 @@
c.Add("Basketball", "Basket", null, 1);
c.Add("Volleyball", "Volley", null, 2);
- AssertEquals("#AAK01", 4, c.Count);
+ Assertion.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"]);
+ Assertion.AssertEquals("#AAK02", "Baseball", c[1]);
+ Assertion.AssertEquals("#AAK03", "Football", c[4]);
+ Assertion.AssertEquals("#AAK04", "Basketball", c["Basket"]);
+ Assertion.AssertEquals("#AAK05", "Volleyball", c["Volley"]);
}
// Test GetEnumerator method
- public void TestGetEnumerator ()
+ [Test]
+ public void GetEnumerator ()
{
Collection c;
IEnumerator e;
@@ -179,22 +181,23 @@
e = c.GetEnumerator();
- AssertNotNull("#GE01", e);
+ Assertion.AssertNotNull("#GE01", e);
while (e.MoveNext()) {
- AssertEquals("#GE02." + i.ToString(), o[i], e.Current);
+ Assertion.AssertEquals("#GE02." + i.ToString(), o[i], e.Current);
i++;
}
e.Reset();
e.MoveNext();
- AssertEquals("#GE03", o[0], e.Current);
+ Assertion.AssertEquals("#GE03", o[0], e.Current);
}
// Test GetEnumerator method again, this time using foreach
- public void Testforeach ()
+ [Test]
+ public void Foreach ()
{
Collection c;
object[] o = new object[4] {typeof(int),
@@ -210,14 +213,15 @@
foreach (object item in c) {
- AssertEquals("#fe01." + i.ToString(), o[i], item);
+ Assertion.AssertEquals("#fe01." + i.ToString(), o[i], item);
i++;
}
}
// Test Remove method with Index
- public void TestRemoveNoKey ()
+ [Test]
+ public void RemoveNoKey ()
{
Collection c;
@@ -228,34 +232,35 @@
c.Add(typeof(string), null, null, null);
c.Add(typeof(object), null, null, null);
- AssertEquals("#RNK01", 4, c.Count);
+ Assertion.AssertEquals("#RNK01", 4, c.Count);
c.Remove(3);
- AssertEquals("#RNK02", 3, c.Count);
+ Assertion.AssertEquals("#RNK02", 3, c.Count);
// Collection class is 1-based
- AssertEquals("#RNK03", typeof(object), c[3]);
+ Assertion.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]);
+ Assertion.AssertEquals("#RNK04", 2, c.Count);
+ Assertion.AssertEquals("#RNK05", typeof(double), c[1]);
+ Assertion.AssertEquals("#RNK06", typeof(object), c[2]);
c.Remove(2);
- AssertEquals("#RNK07", 1, c.Count);
- AssertEquals("#RNK08", typeof(double), c[1]);
+ Assertion.AssertEquals("#RNK07", 1, c.Count);
+ Assertion.AssertEquals("#RNK08", typeof(double), c[1]);
c.Remove(1);
- AssertEquals("#RNK09", 0, c.Count);
+ Assertion.AssertEquals("#RNK09", 0, c.Count);
}
// Test Remove method with Key
- public void TestRemoveKey ()
+ [Test]
+ public void RemoveKey ()
{
Collection c;
@@ -266,35 +271,36 @@
c.Add("Basketball", "Basket", null, null);
c.Add("Volleyball", "Volley", null, null);
- AssertEquals("#RK01", 4, c.Count);
+ Assertion.AssertEquals("#RK01", 4, c.Count);
c.Remove("Foot");
- AssertEquals("#RK02", 3, c.Count);
- AssertEquals("#RK03", "Basketball", c["Basket"]);
+ Assertion.AssertEquals("#RK02", 3, c.Count);
+ Assertion.AssertEquals("#RK03", "Basketball", c["Basket"]);
// Collection class is 1-based
- AssertEquals("#RK04", "Volleyball", c[3]);
+ Assertion.AssertEquals("#RK04", "Volleyball", c[3]);
c.Remove("Base");
- AssertEquals("#RK05", 2, c.Count);
- AssertEquals("#RK06", "Basketball", c[1]);
- AssertEquals("#RK07", "Volleyball", c["Volley"]);
+ Assertion.AssertEquals("#RK05", 2, c.Count);
+ Assertion.AssertEquals("#RK06", "Basketball", c[1]);
+ Assertion.AssertEquals("#RK07", "Volleyball", c["Volley"]);
c.Remove(2);
- AssertEquals("#RK08", 1, c.Count);
- AssertEquals("#RK09", "Basketball", c[1]);
- AssertEquals("#RK10", "Basketball", c["Basket"]);
+ Assertion.AssertEquals("#RK08", 1, c.Count);
+ Assertion.AssertEquals("#RK09", "Basketball", c[1]);
+ Assertion.AssertEquals("#RK10", "Basketball", c["Basket"]);
c.Remove(1);
- AssertEquals("#RK11", 0, c.Count);
+ Assertion.AssertEquals("#RK11", 0, c.Count);
}
// Test all the Exceptions we're supposed to throw
- public void TestException ()
+ [Test]
+ public void Exception ()
{
Collection c;
bool caughtException = false;
@@ -306,11 +312,11 @@
object o = c[0];
}
catch (Exception e) {
- AssertEquals("#E01", typeof(IndexOutOfRangeException), e.GetType());
+ Assertion.AssertEquals("#E01", typeof(IndexOutOfRangeException), e.GetType());
caughtException = true;
}
- AssertEquals("#E02", true, caughtException);
+ Assertion.AssertEquals("#E02", true, caughtException);
c.Add("Baseball", "Base", null, null);
c.Add("Football", "Foot", null, null);
@@ -324,11 +330,11 @@
object o = c[5];
}
catch (Exception e) {
- AssertEquals("#E03", typeof(IndexOutOfRangeException), e.GetType());
+ Assertion.AssertEquals("#E03", typeof(IndexOutOfRangeException), e.GetType());
caughtException = true;
}
- AssertEquals("#E04", true, caughtException);
+ Assertion.AssertEquals("#E04", true, caughtException);
caughtException = false;
@@ -337,11 +343,11 @@
object o = c[0];
}
catch (Exception e) {
- AssertEquals("#E05", typeof(IndexOutOfRangeException), e.GetType());
+ Assertion.AssertEquals("#E05", typeof(IndexOutOfRangeException), e.GetType());
caughtException = true;
}
- AssertEquals("#E06", true, caughtException);
+ Assertion.AssertEquals("#E06", true, caughtException);
caughtException = false;
@@ -353,12 +359,12 @@
// FIXME
// VB Language Reference says IndexOutOfRangeException
// here, but MS throws ArgumentException
- // AssertEquals("#E07", typeof(IndexOutOfRangeException), e.GetType());
- AssertEquals("#E07", typeof(ArgumentException), e.GetType());
+ // Assertion.AssertEquals("#E07", typeof(IndexOutOfRangeException), e.GetType());
+ Assertion.AssertEquals("#E07", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#E08", true, caughtException);
+ Assertion.AssertEquals("#E08", true, caughtException);
caughtException = false;
@@ -367,11 +373,11 @@
object o = c[typeof(int)];
}
catch (Exception e) {
- AssertEquals("#E09", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#E09", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#E10", true, caughtException);
+ Assertion.AssertEquals("#E10", true, caughtException);
caughtException = false;
@@ -380,11 +386,11 @@
c.Add("Kickball", "Kick", "Volley", "Foot");
}
catch (Exception e) {
- AssertEquals("#E11", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#E11", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#E12", true, caughtException);
+ Assertion.AssertEquals("#E12", true, caughtException);
caughtException = false;
@@ -393,11 +399,11 @@
c.Add("Kickball", "Foot", null, null);
}
catch (Exception e) {
- AssertEquals("#E13", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#E13", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#E14", true, caughtException);
+ Assertion.AssertEquals("#E14", true, caughtException);
caughtException = false;
@@ -406,11 +412,11 @@
c.Add("Dodgeball", "Dodge", typeof(int), null);
}
catch (Exception e) {
- AssertEquals("#E15", typeof(InvalidCastException), e.GetType());
+ Assertion.AssertEquals("#E15", typeof(InvalidCastException), e.GetType());
caughtException = true;
}
- AssertEquals("#E16", true, caughtException);
+ Assertion.AssertEquals("#E16", true, caughtException);
caughtException = false;
@@ -419,11 +425,11 @@
c.Add("Wallyball", "Wally", null, typeof(int));
}
catch (Exception e) {
- AssertEquals("#E17", typeof(InvalidCastException), e.GetType());
+ Assertion.AssertEquals("#E17", typeof(InvalidCastException), e.GetType());
caughtException = true;
}
- AssertEquals("#E18", true, caughtException);
+ Assertion.AssertEquals("#E18", true, caughtException);
caughtException = false;
@@ -432,11 +438,11 @@
c.Remove(null);
}
catch (Exception e) {
- AssertEquals("#E19", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#E19", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#E20", true, caughtException);
+ Assertion.AssertEquals("#E20", true, caughtException);
caughtException = false;
@@ -445,11 +451,11 @@
c.Remove("Golf");
}
catch (Exception e) {
- AssertEquals("#E21", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#E21", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#E22", true, caughtException);
+ Assertion.AssertEquals("#E22", true, caughtException);
caughtException = false;
@@ -458,11 +464,11 @@
c.Remove(10);
}
catch (Exception e) {
- AssertEquals("#E23", typeof(IndexOutOfRangeException), e.GetType());
+ Assertion.AssertEquals("#E23", typeof(IndexOutOfRangeException), e.GetType());
caughtException = true;
}
- AssertEquals("#E24", true, caughtException);
+ Assertion.AssertEquals("#E24", true, caughtException);
caughtException = false;
@@ -476,12 +482,12 @@
// FIXME
// On-line help says InvalidOperationException here,
// but MS throws IndexOutOfRangeException
- // AssertEquals("#E25", typeof(InvalidOperationException), e.GetType());
- AssertEquals("#E25", typeof(IndexOutOfRangeException), e.GetType());
+ // Assertion.AssertEquals("#E25", typeof(InvalidOperationException), e.GetType());
+ Assertion.AssertEquals("#E25", typeof(IndexOutOfRangeException), e.GetType());
caughtException = true;
}
- AssertEquals("#E26", true, caughtException);
+ Assertion.AssertEquals("#E26", true, caughtException);
caughtException = false;
@@ -497,14 +503,14 @@
catch (Exception e) {
// FIXME
// On-line help says this should throw an error. MS doesn't.
- AssertEquals("#E27", typeof(InvalidOperationException), e.GetType());
+ Assertion.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);
+ // Assertion.AssertEquals("#E28", true, caughtException);
+ Assertion.AssertEquals("#E28", false, caughtException);
caughtException = false;
@@ -520,14 +526,14 @@
catch (Exception e) {
// FIXME
// On-line help says this should throw an error. MS doesn't.
- AssertEquals("#E29", typeof(InvalidOperationException), e.GetType());
+ Assertion.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);
+ // Assertion.AssertEquals("#E30", true, caughtException);
+ Assertion.AssertEquals("#E30", false, caughtException);
caughtException = false;
}
Index: Test/ConversionTest.cs
===================================================================
RCS file: /cvs/public/mcs/class/Microsoft.VisualBasic/Test/ConversionTest.cs,v
retrieving revision 1.2
diff -u -r1.2 ConversionTest.cs
--- Test/ConversionTest.cs 22 Jun 2002 10:15:34 -0000 1.2
+++ Test/ConversionTest.cs 11 Mar 2003 11:21:46 -0000
@@ -13,137 +13,135 @@
namespace MonoTests.Microsoft.VisualBasic
{
- public class ConversionTest : TestCase
+ [TestFixture]
+ public class ConversionTest
{
- public ConversionTest() : base ("Microsoft.VisualBasic.Conversion") {}
- public ConversionTest(string name) : base(name) {}
+ [SetUp]
+ public void GetReady() {}
- protected override void SetUp() {}
- protected override void TearDown() {}
+ [TearDown]
+ public void Clear() {}
- public static ITest Suite {
- get {
- return new TestSuite(typeof(ConversionTest));
- }
- }
-
- public void TestErrorToStringEmpty() {
+ [Test]
+ public void ErrorToStringEmpty() {
// FIXME : Do something here, but write the ErrorToString code first :-)
}
- public void TestErrorToStringNumber() {
+ [Test]
+ public void ErrorToStringNumber() {
// FIXME : Do something here, but write the ErrorToString code first :-)
}
// Test the Fix function
- public void TestFix() {
+ [Test]
+ public void Fix() {
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));
+ Assertion.AssertEquals("#F01", System.Int16.MaxValue, Conversion.Fix(System.Int16.MaxValue));
+ Assertion.AssertEquals("#F02", System.Int16.MinValue, Conversion.Fix(System.Int16.MinValue));
+ Assertion.AssertEquals("#F03", System.Int32.MaxValue, Conversion.Fix(System.Int32.MaxValue));
+ Assertion.AssertEquals("#F04", System.Int32.MinValue, Conversion.Fix(System.Int32.MinValue));
+ Assertion.AssertEquals("#F05", System.Int64.MaxValue, Conversion.Fix(System.Int64.MaxValue));
+ Assertion.AssertEquals("#F06", System.Int64.MinValue, Conversion.Fix(System.Int64.MinValue));
+ Assertion.AssertEquals("#F07", (System.Single)Math.Floor(System.Single.MaxValue), Conversion.Fix(System.Single.MaxValue));
+ Assertion.AssertEquals("#F08", -1 * (System.Single)Math.Floor(-1 * System.Single.MinValue), Conversion.Fix(System.Single.MinValue));
+ Assertion.AssertEquals("#F09", Math.Floor(System.Double.MaxValue), Conversion.Fix(System.Double.MaxValue));
+ Assertion.AssertEquals("#F10", -1 * Math.Floor(-1 * System.Double.MinValue), Conversion.Fix(System.Double.MinValue));
+ Assertion.AssertEquals("#F11", Decimal.Floor(System.Decimal.MaxValue), Conversion.Fix(System.Decimal.MaxValue));
+ Assertion.AssertEquals("#F12", -1 * Decimal.Floor(-1 * System.Decimal.MinValue), Conversion.Fix(System.Decimal.MinValue));
Sng = 99.1F;
- AssertEquals("#F13", 99F, Conversion.Fix(Sng));
+ Assertion.AssertEquals("#F13", 99F, Conversion.Fix(Sng));
Sng = 99.6F;
- AssertEquals("#F14", 99F, Conversion.Fix(Sng));
+ Assertion.AssertEquals("#F14", 99F, Conversion.Fix(Sng));
Sng = -99.1F;
- AssertEquals("#F15", -99F, Conversion.Fix(Sng));
+ Assertion.AssertEquals("#F15", -99F, Conversion.Fix(Sng));
Sng = -99.6F;
- AssertEquals("#F16", -99F, Conversion.Fix(Sng));
+ Assertion.AssertEquals("#F16", -99F, Conversion.Fix(Sng));
Dbl = 99.1;
- AssertEquals("#F17", 99D, Conversion.Fix(Dbl));
+ Assertion.AssertEquals("#F17", 99D, Conversion.Fix(Dbl));
Dbl = 99.6;
- AssertEquals("#F18", 99D, Conversion.Fix(Dbl));
+ Assertion.AssertEquals("#F18", 99D, Conversion.Fix(Dbl));
Dbl = -99.1;
- AssertEquals("#F19", -99D, Conversion.Fix(Dbl));
+ Assertion.AssertEquals("#F19", -99D, Conversion.Fix(Dbl));
Dbl = -99.6;
- AssertEquals("#F20", -99D, Conversion.Fix(Dbl));
+ Assertion.AssertEquals("#F20", -99D, Conversion.Fix(Dbl));
Dec = 99.1M;
- AssertEquals("#F21", 99M, Conversion.Fix(Dec));
+ Assertion.AssertEquals("#F21", 99M, Conversion.Fix(Dec));
Dec = 99.6M;
- AssertEquals("#F22", 99M, Conversion.Fix(Dec));
+ Assertion.AssertEquals("#F22", 99M, Conversion.Fix(Dec));
Dec = -99.1M;
- AssertEquals("#F23", -99M, Conversion.Fix(Dec));
+ Assertion.AssertEquals("#F23", -99M, Conversion.Fix(Dec));
Dec = -99.6M;
- AssertEquals("#F24", -99M, Conversion.Fix(Dec));
+ Assertion.AssertEquals("#F24", -99M, Conversion.Fix(Dec));
Dbl = 99.1;
S = Dbl.ToString();
- AssertEquals("#F25", 99D, Conversion.Fix(S));
+ Assertion.AssertEquals("#F25", 99D, Conversion.Fix(S));
Dbl = 99.6;
S = Dbl.ToString();
- AssertEquals("#F26", 99D, Conversion.Fix(S));
+ Assertion.AssertEquals("#F26", 99D, Conversion.Fix(S));
Dbl = -99.1;
S = Dbl.ToString();
- AssertEquals("#F27", -99D, Conversion.Fix(S));
+ Assertion.AssertEquals("#F27", -99D, Conversion.Fix(S));
Dbl = -99.6;
S = Dbl.ToString();
- AssertEquals("#F28", -99D, Conversion.Fix(S));
+ Assertion.AssertEquals("#F28", -99D, Conversion.Fix(S));
Dbl = 99.1;
O = Dbl;
- AssertEquals("#F29", 99D, Conversion.Fix(O));
+ Assertion.AssertEquals("#F29", 99D, Conversion.Fix(O));
Sng = 99.6F;
O = Sng;
- AssertEquals("#F30", (System.Object)99F, Conversion.Fix(O));
+ Assertion.AssertEquals("#F30", (System.Object)99F, Conversion.Fix(O));
Dbl = -99.1;
O = Dbl;
- AssertEquals("#F31", -99D, Conversion.Fix(O));
+ Assertion.AssertEquals("#F31", -99D, Conversion.Fix(O));
Dec = -99.6M;
O = Dec;
- AssertEquals("#F32", (System.Object)(-99M), Conversion.Fix(O));
+ Assertion.AssertEquals("#F32", (System.Object)(-99M), Conversion.Fix(O));
O = typeof(int);
@@ -153,133 +151,134 @@
Conversion.Fix(O);
}
catch (Exception e) {
- AssertEquals("#F33", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#F33", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#F34", true, caughtException);
+ Assertion.AssertEquals("#F34", true, caughtException);
caughtException = false;
try {
Conversion.Fix(null);
}
catch (Exception e) {
- AssertEquals("#F35", typeof(ArgumentNullException), e.GetType());
+ Assertion.AssertEquals("#F35", typeof(ArgumentNullException), e.GetType());
caughtException = true;
}
- AssertEquals("#F36", true, caughtException);
+ Assertion.AssertEquals("#F36", true, caughtException);
}
// Test the Int function
- public void TestInt() {
+ [Test]
+ public void Int() {
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));
+ Assertion.AssertEquals("#I01", System.Int16.MaxValue, Conversion.Int(System.Int16.MaxValue));
+ Assertion.AssertEquals("#I02", System.Int16.MinValue, Conversion.Int(System.Int16.MinValue));
+ Assertion.AssertEquals("#I03", System.Int32.MaxValue, Conversion.Int(System.Int32.MaxValue));
+ Assertion.AssertEquals("#I04", System.Int32.MinValue, Conversion.Int(System.Int32.MinValue));
+ Assertion.AssertEquals("#I05", System.Int64.MaxValue, Conversion.Int(System.Int64.MaxValue));
+ Assertion.AssertEquals("#I06", System.Int64.MinValue, Conversion.Int(System.Int64.MinValue));
+ Assertion.AssertEquals("#I07", (System.Single)Math.Floor(System.Single.MaxValue), Conversion.Int(System.Single.MaxValue));
+ Assertion.AssertEquals("#I08", (System.Single)Math.Floor(System.Single.MinValue), Conversion.Int(System.Single.MinValue));
+ Assertion.AssertEquals("#I09", Math.Floor(System.Double.MaxValue), Conversion.Int(System.Double.MaxValue));
+ Assertion.AssertEquals("#I10", Math.Floor(System.Double.MinValue), Conversion.Int(System.Double.MinValue));
+ Assertion.AssertEquals("#I11", Decimal.Floor(System.Decimal.MaxValue), Conversion.Int(System.Decimal.MaxValue));
+ Assertion.AssertEquals("#I12", Decimal.Floor(System.Decimal.MinValue), Conversion.Int(System.Decimal.MinValue));
Sng = 99.1F;
- AssertEquals("#I13", 99F, Conversion.Int(Sng));
+ Assertion.AssertEquals("#I13", 99F, Conversion.Int(Sng));
Sng = 99.6F;
- AssertEquals("#I14", 99F, Conversion.Int(Sng));
+ Assertion.AssertEquals("#I14", 99F, Conversion.Int(Sng));
Sng = -99.1F;
- AssertEquals("#I15", -100F, Conversion.Int(Sng));
+ Assertion.AssertEquals("#I15", -100F, Conversion.Int(Sng));
Sng = -99.6F;
- AssertEquals("#I16", -100F, Conversion.Int(Sng));
+ Assertion.AssertEquals("#I16", -100F, Conversion.Int(Sng));
Dbl = 99.1;
- AssertEquals("#I17", 99D, Conversion.Int(Dbl));
+ Assertion.AssertEquals("#I17", 99D, Conversion.Int(Dbl));
Dbl = 99.6;
- AssertEquals("#I18", 99D, Conversion.Int(Dbl));
+ Assertion.AssertEquals("#I18", 99D, Conversion.Int(Dbl));
Dbl = -99.1;
- AssertEquals("#I19", -100D, Conversion.Int(Dbl));
+ Assertion.AssertEquals("#I19", -100D, Conversion.Int(Dbl));
Dbl = -99.6;
- AssertEquals("#I20", -100D, Conversion.Int(Dbl));
+ Assertion.AssertEquals("#I20", -100D, Conversion.Int(Dbl));
Dec = 99.1M;
- AssertEquals("#I21", 99M, Conversion.Int(Dec));
+ Assertion.AssertEquals("#I21", 99M, Conversion.Int(Dec));
Dec = 99.6M;
- AssertEquals("#I22", 99M, Conversion.Int(Dec));
+ Assertion.AssertEquals("#I22", 99M, Conversion.Int(Dec));
Dec = -99.1M;
- AssertEquals("#I23", -100M, Conversion.Int(Dec));
+ Assertion.AssertEquals("#I23", -100M, Conversion.Int(Dec));
Dec = -99.6M;
- AssertEquals("#I24", -100M, Conversion.Int(Dec));
+ Assertion.AssertEquals("#I24", -100M, Conversion.Int(Dec));
Dbl = 99.1;
S = Dbl.ToString();
- AssertEquals("#I25", 99D, Conversion.Int(S));
+ Assertion.AssertEquals("#I25", 99D, Conversion.Int(S));
Dbl = 99.6;
S = Dbl.ToString();
- AssertEquals("#I26", 99D, Conversion.Int(S));
+ Assertion.AssertEquals("#I26", 99D, Conversion.Int(S));
Dbl = -99.1;
S = Dbl.ToString();
- AssertEquals("#I27", -100D, Conversion.Int(S));
+ Assertion.AssertEquals("#I27", -100D, Conversion.Int(S));
Dbl = -99.6;
S = Dbl.ToString();
- AssertEquals("#I28", -100D, Conversion.Int(S));
+ Assertion.AssertEquals("#I28", -100D, Conversion.Int(S));
Dbl = 99.1;
O = Dbl;
- AssertEquals("#I29", 99D, Conversion.Int(O));
+ Assertion.AssertEquals("#I29", 99D, Conversion.Int(O));
Sng = 99.6F;
O = Sng;
- AssertEquals("#I30", 99F, Conversion.Int(O));
+ Assertion.AssertEquals("#I30", 99F, Conversion.Int(O));
Dbl = -99.1;
O = Dbl;
- AssertEquals("#I31", -100D, Conversion.Int(O));
+ Assertion.AssertEquals("#I31", -100D, Conversion.Int(O));
Dec = -99.6M;
O = Dec;
- AssertEquals("#I32", -100M, Conversion.Int(O));
+ Assertion.AssertEquals("#I32", -100M, Conversion.Int(O));
// test the exceptions it's supposed to throw
@@ -290,36 +289,37 @@
Conversion.Fix(O);
}
catch (Exception e) {
- AssertEquals("#I33", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#I33", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#I34", true, caughtException);
+ Assertion.AssertEquals("#I34", true, caughtException);
caughtException = false;
try {
Conversion.Int(null);
}
catch (Exception e) {
- AssertEquals("#I35", typeof(ArgumentNullException), e.GetType());
+ Assertion.AssertEquals("#I35", typeof(ArgumentNullException), e.GetType());
caughtException = true;
}
- AssertEquals("#I36", true, caughtException);
+ Assertion.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));
+ [Test]
+ public void Hex() {
+ Assertion.AssertEquals("#H01", "FF", Conversion.Hex(System.Byte.MaxValue));
+ Assertion.AssertEquals("#H02", "0", Conversion.Hex(System.Byte.MinValue));
+ Assertion.AssertEquals("#H03", "7FFF", Conversion.Hex(System.Int16.MaxValue));
+ Assertion.AssertEquals("#H04", "8000", Conversion.Hex(System.Int16.MinValue));
+ Assertion.AssertEquals("#H05", "7FFFFFFF", Conversion.Hex(System.Int32.MaxValue));
+ Assertion.AssertEquals("#H06", "80000000", Conversion.Hex(System.Int32.MinValue));
+ Assertion.AssertEquals("#H07", "7FFFFFFFFFFFFFFF", Conversion.Hex(System.Int64.MaxValue));
+ Assertion.AssertEquals("#H08", "8000000000000000", Conversion.Hex(System.Int64.MinValue));
System.Byte UI8;
System.Int16 I16;
@@ -329,107 +329,107 @@
System.String S;
UI8 = 15;
- AssertEquals("#H09", "F", Conversion.Hex(UI8));
+ Assertion.AssertEquals("#H09", "F", Conversion.Hex(UI8));
I16 = System.Byte.MaxValue;
- AssertEquals("#H10", "FF", Conversion.Hex(I16));
+ Assertion.AssertEquals("#H10", "FF", Conversion.Hex(I16));
I16 = (System.Int16)((I16 + 1) * -1);
- AssertEquals("#H11", "FF00", Conversion.Hex(I16));
+ Assertion.AssertEquals("#H11", "FF00", Conversion.Hex(I16));
I16 = -2;
- AssertEquals("#H12", "FFFE", Conversion.Hex(I16));
+ Assertion.AssertEquals("#H12", "FFFE", Conversion.Hex(I16));
I32 = System.UInt16.MaxValue;
- AssertEquals("#H13", "FFFF", Conversion.Hex(I32));
+ Assertion.AssertEquals("#H13", "FFFF", Conversion.Hex(I32));
I32 = (I32 + 1) * -1;
- AssertEquals("#H14", "FFFF0000", Conversion.Hex(I32));
+ Assertion.AssertEquals("#H14", "FFFF0000", Conversion.Hex(I32));
I32 = -2;
- AssertEquals("#H15", "FFFFFFFE", Conversion.Hex(I32));
+ Assertion.AssertEquals("#H15", "FFFFFFFE", Conversion.Hex(I32));
I64 = System.UInt32.MaxValue;
- AssertEquals("#H16", "FFFFFFFF", Conversion.Hex(I64));
+ Assertion.AssertEquals("#H16", "FFFFFFFF", Conversion.Hex(I64));
I64 = (I64 + 1) * -1;
- AssertEquals("#H17", "FFFFFFFF00000000", Conversion.Hex(I64));
+ Assertion.AssertEquals("#H17", "FFFFFFFF00000000", Conversion.Hex(I64));
I64 = -2;
- AssertEquals("#H18", "FFFFFFFFFFFFFFFE", Conversion.Hex(I64));
+ Assertion.AssertEquals("#H18", "FFFFFFFFFFFFFFFE", Conversion.Hex(I64));
I16 = System.Byte.MaxValue;
S = I16.ToString();
- AssertEquals("#H19", "FF", Conversion.Hex(S));
+ Assertion.AssertEquals("#H19", "FF", Conversion.Hex(S));
I16 = (System.Int16)((I16 + 1) * -1);
S = I16.ToString();
- AssertEquals("#H20", "FFFFFF00", Conversion.Hex(S));
+ Assertion.AssertEquals("#H20", "FFFFFF00", Conversion.Hex(S));
I16 = -1;
S = I16.ToString();
- AssertEquals("#H21", "FFFFFFFF", Conversion.Hex(S));
+ Assertion.AssertEquals("#H21", "FFFFFFFF", Conversion.Hex(S));
I32 = System.UInt16.MaxValue;
S = I32.ToString();
- AssertEquals("#H22", "FFFF", Conversion.Hex(S));
+ Assertion.AssertEquals("#H22", "FFFF", Conversion.Hex(S));
I32 = (I32 + 1) * -1;
S = I32.ToString();
- AssertEquals("#H23", "FFFF0000", Conversion.Hex(S));
+ Assertion.AssertEquals("#H23", "FFFF0000", Conversion.Hex(S));
I32 = -2;
S = I32.ToString();
- AssertEquals("#H24", "FFFFFFFE", Conversion.Hex(S));
+ Assertion.AssertEquals("#H24", "FFFFFFFE", Conversion.Hex(S));
I64 = System.UInt32.MaxValue;
S = I64.ToString();
- AssertEquals("#H25", "FFFFFFFF", Conversion.Hex(S));
+ Assertion.AssertEquals("#H25", "FFFFFFFF", Conversion.Hex(S));
I64 = (I64 + 1) * -1;
S = I64.ToString();
- AssertEquals("#H26", "FFFFFFFF00000000", Conversion.Hex(S));
+ Assertion.AssertEquals("#H26", "FFFFFFFF00000000", Conversion.Hex(S));
UI8 = System.Byte.MaxValue;
O = UI8;
- AssertEquals("#H27", "FF", Conversion.Hex(O));
+ Assertion.AssertEquals("#H27", "FF", Conversion.Hex(O));
I16 = System.Byte.MaxValue;
O = I16;
- AssertEquals("#H28", "FF", Conversion.Hex(O));
+ Assertion.AssertEquals("#H28", "FF", Conversion.Hex(O));
I16 = (System.Int16)((I16 + 1) * -1);
O = I16;
- AssertEquals("#H29", "FF00", Conversion.Hex(O));
+ Assertion.AssertEquals("#H29", "FF00", Conversion.Hex(O));
I16 = -2;
O = I16;
- AssertEquals("#H30", "FFFE", Conversion.Hex(O));
+ Assertion.AssertEquals("#H30", "FFFE", Conversion.Hex(O));
I32 = System.UInt16.MaxValue;
O = I32;
- AssertEquals("#H31", "FFFF", Conversion.Hex(O));
+ Assertion.AssertEquals("#H31", "FFFF", Conversion.Hex(O));
I32 = (I32 + 1) * -1;
O = I32;
- AssertEquals("#H32", "FFFF0000", Conversion.Hex(O));
+ Assertion.AssertEquals("#H32", "FFFF0000", Conversion.Hex(O));
I32 = -2;
O = I32;
- AssertEquals("#H33", "FFFFFFFE", Conversion.Hex(O));
+ Assertion.AssertEquals("#H33", "FFFFFFFE", Conversion.Hex(O));
I64 = System.UInt32.MaxValue;
O = I64;
- AssertEquals("#H34", "FFFFFFFF", Conversion.Hex(O));
+ Assertion.AssertEquals("#H34", "FFFFFFFF", Conversion.Hex(O));
I64 = (I64 + 1) * -1;
O = I64;
- AssertEquals("#H35", "FFFFFFFF00000000", Conversion.Hex(O));
+ Assertion.AssertEquals("#H35", "FFFFFFFF00000000", Conversion.Hex(O));
I64 = -2;
O = I64;
// FIXME : MS doesn't pass this test
- //AssertEquals("#H35", "FFFFFFFFFFFFFFFE", Conversion.Hex(O));
+ //Assertion.AssertEquals("#H35", "FFFFFFFFFFFFFFFE", Conversion.Hex(O));
O = typeof(int);
@@ -438,11 +438,11 @@
Conversion.Hex(O);
}
catch (Exception e) {
- AssertEquals("#H36", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#H36", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#H37", true, caughtException);
+ Assertion.AssertEquals("#H37", true, caughtException);
caughtException = false;
@@ -450,23 +450,24 @@
Conversion.Hex(null);
}
catch (Exception e) {
- AssertEquals("#H38", typeof(ArgumentNullException), e.GetType());
+ Assertion.AssertEquals("#H38", typeof(ArgumentNullException), e.GetType());
caughtException = true;
}
- AssertEquals("#H39", true, caughtException);
+ Assertion.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));
+ [Test]
+ public void Oct() {
+ Assertion.AssertEquals("#O01", "377", Conversion.Oct(System.Byte.MaxValue));
+ Assertion.AssertEquals("#O02", "0", Conversion.Oct(System.Byte.MinValue));
+ Assertion.AssertEquals("#O03", "77777", Conversion.Oct(System.Int16.MaxValue));
+ Assertion.AssertEquals("#O04", "100000", Conversion.Oct(System.Int16.MinValue));
+ Assertion.AssertEquals("#O05", "17777777777", Conversion.Oct(System.Int32.MaxValue));
+ Assertion.AssertEquals("#O06", "20000000000", Conversion.Oct(System.Int32.MinValue));
+ Assertion.AssertEquals("#O07", "777777777777777777777", Conversion.Oct(System.Int64.MaxValue));
+ //Assertion.AssertEquals("#O08", "1000000000000000000000", Conversion.Oct(System.Int64.MinValue));
System.Byte UI8;
System.Int16 I16;
@@ -476,108 +477,108 @@
System.String S;
UI8 = 15;
- AssertEquals("#O09", "17", Conversion.Oct(UI8));
+ Assertion.AssertEquals("#O09", "17", Conversion.Oct(UI8));
I16 = System.Byte.MaxValue;
- AssertEquals("#O10", "377", Conversion.Oct(I16));
+ Assertion.AssertEquals("#O10", "377", Conversion.Oct(I16));
I16 = (System.Int16)((I16 + 1) * -1);
- AssertEquals("#O11", "177400", Conversion.Oct(I16));
+ Assertion.AssertEquals("#O11", "177400", Conversion.Oct(I16));
I16 = -2;
- AssertEquals("#O12", "177776", Conversion.Oct(I16));
+ Assertion.AssertEquals("#O12", "177776", Conversion.Oct(I16));
I32 = System.UInt16.MaxValue;
- AssertEquals("#O13", "177777", Conversion.Oct(I32));
+ Assertion.AssertEquals("#O13", "177777", Conversion.Oct(I32));
I32 = (I32 + 1) * -1;
- AssertEquals("#O14", "37777600000", Conversion.Oct(I32));
+ Assertion.AssertEquals("#O14", "37777600000", Conversion.Oct(I32));
I32 = -2;
- AssertEquals("#O15", "37777777776", Conversion.Oct(I32));
+ Assertion.AssertEquals("#O15", "37777777776", Conversion.Oct(I32));
I64 = System.UInt32.MaxValue;
- AssertEquals("#O16", "37777777777", Conversion.Oct(I64));
+ Assertion.AssertEquals("#O16", "37777777777", Conversion.Oct(I64));
I64 = (I64 + 1) * -1;
- AssertEquals("#O17", "1777777777740000000000", Conversion.Oct(I64));
+ Assertion.AssertEquals("#O17", "1777777777740000000000", Conversion.Oct(I64));
I64 = -2;
- AssertEquals("#O18", "1777777777777777777776", Conversion.Oct(I64));
+ Assertion.AssertEquals("#O18", "1777777777777777777776", Conversion.Oct(I64));
I16 = System.Byte.MaxValue;
S = I16.ToString();
- AssertEquals("#O19", "377", Conversion.Oct(S));
+ Assertion.AssertEquals("#O19", "377", Conversion.Oct(S));
I16 = (System.Int16)((I16 + 1) * -1);
S = I16.ToString();
- AssertEquals("#O20", "37777777400", Conversion.Oct(S));
+ Assertion.AssertEquals("#O20", "37777777400", Conversion.Oct(S));
I16 = -2;
S = I16.ToString();
- AssertEquals("#O21", "37777777776", Conversion.Oct(S));
+ Assertion.AssertEquals("#O21", "37777777776", Conversion.Oct(S));
I32 = System.UInt16.MaxValue;
S = I32.ToString();
- AssertEquals("#O22", "177777", Conversion.Oct(S));
+ Assertion.AssertEquals("#O22", "177777", Conversion.Oct(S));
I32 = (I32 + 1) * -1;
S = I32.ToString();
- AssertEquals("#O23", "37777600000", Conversion.Oct(S));
+ Assertion.AssertEquals("#O23", "37777600000", Conversion.Oct(S));
I32 = -2;
S = I32.ToString();
- AssertEquals("#O24", "37777777776", Conversion.Oct(S));
+ Assertion.AssertEquals("#O24", "37777777776", Conversion.Oct(S));
I64 = System.UInt32.MaxValue;
S = I64.ToString();
- AssertEquals("#O25", "37777777777", Conversion.Oct(S));
+ Assertion.AssertEquals("#O25", "37777777777", Conversion.Oct(S));
I64 = (I64 + 1) * -1;
S = I64.ToString();
- AssertEquals("#O26", "1777777777740000000000", Conversion.Oct(S));
+ Assertion.AssertEquals("#O26", "1777777777740000000000", Conversion.Oct(S));
UI8 = System.Byte.MaxValue;
O = UI8;
- AssertEquals("#O27", "377", Conversion.Oct(O));
+ Assertion.AssertEquals("#O27", "377", Conversion.Oct(O));
I16 = System.Byte.MaxValue;
O = I16;
- AssertEquals("#O28", "377", Conversion.Oct(O));
+ Assertion.AssertEquals("#O28", "377", Conversion.Oct(O));
I16 = (System.Int16)((I16 + 1) * -1);
O = I16;
- AssertEquals("#O29", "177400", Conversion.Oct(O));
+ Assertion.AssertEquals("#O29", "177400", Conversion.Oct(O));
I16 = -2;
O = I16;
- AssertEquals("#O29", "177776", Conversion.Oct(O));
+ Assertion.AssertEquals("#O29", "177776", Conversion.Oct(O));
I32 = System.UInt16.MaxValue;
O = I32;
- AssertEquals("#O30", "177777", Conversion.Oct(O));
+ Assertion.AssertEquals("#O30", "177777", Conversion.Oct(O));
I32 = (I32 + 1) * -1;
O = I32;
- AssertEquals("#O31", "37777600000", Conversion.Oct(O));
+ Assertion.AssertEquals("#O31", "37777600000", Conversion.Oct(O));
I32 = -2;
O = I32;
- AssertEquals("#O32", "37777777776", Conversion.Oct(O));
+ Assertion.AssertEquals("#O32", "37777777776", Conversion.Oct(O));
I64 = System.UInt32.MaxValue;
O = I64;
- AssertEquals("#O33", "37777777777", Conversion.Oct(O));
+ Assertion.AssertEquals("#O33", "37777777777", Conversion.Oct(O));
I64 = (I64 + 1) * -1;
O = I64;
- AssertEquals("#O34", "1777777777740000000000", Conversion.Oct(O));
+ Assertion.AssertEquals("#O34", "1777777777740000000000", Conversion.Oct(O));
I64 = -2;
O = I64;
// FIXME: MS doesn't pass this test
- // AssertEquals("#O35", "1777777777777777777776", Conversion.Oct(O));
+ // Assertion.AssertEquals("#O35", "1777777777777777777776", Conversion.Oct(O));
O = typeof(int);
@@ -586,11 +587,11 @@
Conversion.Oct(O);
}
catch (Exception e) {
- AssertEquals("#O36", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#O36", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#O37", true, caughtException);
+ Assertion.AssertEquals("#O37", true, caughtException);
caughtException = false;
@@ -598,17 +599,18 @@
Conversion.Oct(null);
}
catch (Exception e) {
- AssertEquals("#O38", typeof(ArgumentNullException), e.GetType());
+ Assertion.AssertEquals("#O38", typeof(ArgumentNullException), e.GetType());
caughtException = true;
}
- AssertEquals("#O39", true, caughtException);
+ Assertion.AssertEquals("#O39", true, caughtException);
}
// test the Str function
- public void TestStr() {
- AssertEquals("#S01", "-1", Conversion.Str(-1));
- AssertEquals("#S02", " 1", Conversion.Str(1));
+ [Test]
+ public void Str() {
+ Assertion.AssertEquals("#S01", "-1", Conversion.Str(-1));
+ Assertion.AssertEquals("#S02", " 1", Conversion.Str(1));
bool caughtException = false;
Object O = typeof(int);
@@ -617,11 +619,11 @@
Conversion.Str(O);
}
catch (Exception e) {
- AssertEquals("#S03", typeof(InvalidCastException), e.GetType());
+ Assertion.AssertEquals("#S03", typeof(InvalidCastException), e.GetType());
caughtException = true;
}
- AssertEquals("#S04", true, caughtException);
+ Assertion.AssertEquals("#S04", true, caughtException);
caughtException = false;
@@ -629,21 +631,22 @@
Conversion.Str(null);
}
catch (Exception e) {
- AssertEquals("#S05", typeof(ArgumentNullException), e.GetType());
+ Assertion.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"));
+ [Test]
+ public void Val() {
+ Assertion.AssertEquals("#V01", 4, Conversion.Val('4'));
+ Assertion.AssertEquals("#V02", -3542.76, Conversion.Val(" - 3 5 .4 2 7 6E+ 0 0 2 "));
+ Assertion.AssertEquals("#V03", 255D, Conversion.Val("&HFF"));
+ Assertion.AssertEquals("#V04", 255D, Conversion.Val("&o377"));
System.Object O = " - 3 5 .4 7 6E+ 0 0 3";
- AssertEquals("#V05", -35476D, Conversion.Val(O));
+ Assertion.AssertEquals("#V05", -35476D, Conversion.Val(O));
bool caughtException;
@@ -653,11 +656,11 @@
Conversion.Val("3E+9999999");
}
catch (Exception e) {
- AssertEquals("#V06", typeof(OverflowException), e.GetType());
+ Assertion.AssertEquals("#V06", typeof(OverflowException), e.GetType());
caughtException = true;
}
- AssertEquals("#V07", true, caughtException);
+ Assertion.AssertEquals("#V07", true, caughtException);
caughtException = false;
@@ -665,10 +668,10 @@
Conversion.Val(typeof(int));
}
catch (Exception e) {
- AssertEquals("#V08", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#V08", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#V09", true, caughtException);
+ Assertion.AssertEquals("#V09", true, caughtException);
}
}
}
Index: Test/DateAndTimeTest.cs
===================================================================
RCS file: /cvs/public/mcs/class/Microsoft.VisualBasic/Test/DateAndTimeTest.cs,v
retrieving revision 1.3
diff -u -r1.3 DateAndTimeTest.cs
--- Test/DateAndTimeTest.cs 28 Oct 2002 08:50:49 -0000 1.3
+++ Test/DateAndTimeTest.cs 11 Mar 2003 11:21:46 -0000
@@ -14,47 +14,46 @@
namespace MonoTests.Microsoft.VisualBasic
{
-
- public class DateAndTimeTest : TestCase {
+ [TestFixture]
+ public class DateAndTimeTest {
private CultureInfo oldcult;
-
- public DateAndTimeTest() : base ("Microsoft.VisualBasic.DateAndTime") {}
- public DateAndTimeTest(string name) : base(name) {}
- protected override void SetUp()
+ [SetUp]
+ public void GetReady()
{
// the current culture determines the result of formatting
oldcult = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo ("");
}
- protected override void TearDown ()
+ [TearDown]
+ public void Clear()
{
Thread.CurrentThread.CurrentCulture = oldcult;
}
- public static ITest Suite {
- get {
- return new TestSuite(typeof(DateAndTimeTest));
- }
- }
-
- public void TestDateString() {
+ [Test]
+ public void DateString()
+ {
string s = DateAndTime.DateString;
DateTime dtNow = DateTime.Today;
- AssertEquals("#DS01", dtNow.ToShortDateString(), DateTime.Parse(s).ToShortDateString());
+ Assertion.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);
+ [Test]
+ public void Today()
+ {
+ Assertion.AssertEquals("#TO01", DateTime.Today, DateAndTime.Today);
// TODO: Add a test for setting Today
}
- public void TestTimer() {
+ [Test]
+ public void Timer()
+ {
double secTimer = DateAndTime.Timer;
DateTime dtNow = DateTime.Now;
double secNow = dtNow.Hour * 3600 + dtNow.Minute * 60 + dtNow.Second + (dtNow.Millisecond + 1) / 1000D;
@@ -67,23 +66,27 @@
double secTimer3 = DateAndTime.Timer;
// should be same time within a reasonable tolerance
- Assert("#TI01", secNow >= secTimer);
- Assert("#TI02: SecTimer2=" + secTimer2 + " secNow=" + secNow, secTimer2 >= secNow);
+ Assertion.Assert("#TI01", secNow >= secTimer);
+ Assertion.Assert("#TI02: SecTimer2=" + secTimer2 + " secNow=" + secNow, secTimer2 >= secNow);
// third timer should be greater than the first
- Assert("#TI03", secTimer3 > secTimer);
+ Assertion.Assert("#TI03", secTimer3 > secTimer);
}
- public void TestNow() {
+ [Test]
+ public void Now()
+ {
DateTime dtNow = DateTime.Now;
DateTime dtTest = DateAndTime.Now;
DateTime dtNow2 = DateTime.Now;
- Assert("#N01", dtTest >= dtNow);
- Assert("#N02", dtNow2 >= dtTest);
+ Assertion.Assert("#N01", dtTest >= dtNow);
+ Assertion.Assert("#N02", dtNow2 >= dtTest);
}
- public void TestTimeOfDay() {
+ [Test]
+ public void TimeOfDay()
+ {
DateTime dtNow = DateTime.Now;
TimeSpan tsNow = new TimeSpan(dtNow.Hour, dtNow.Minute, dtNow.Second);
DateTime dtTest = DateAndTime.TimeOfDay;
@@ -91,13 +94,15 @@
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);
+ Assertion.Assert("#TOD01", tsTest.Ticks >= tsNow.Ticks);
+ Assertion.Assert("#TOD02", tsNow2.Ticks >= tsTest.Ticks);
// TODO: add a test case for setting time of day
}
- public void TestTimeString() {
+ [Test]
+ public void TimeString()
+ {
DateTime dtNow = DateTime.Now;
TimeSpan tsNow = new TimeSpan(dtNow.Hour, dtNow.Minute, dtNow.Second);
string s = DateAndTime.TimeString;
@@ -106,17 +111,19 @@
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);
+ Assertion.Assert("#TS01", tsTest.Ticks >= tsNow.Ticks);
+ Assertion.Assert("#TS02", tsNow2.Ticks >= tsTest.Ticks);
// TODO: add a test case for setting TimeString
}
- public void TestDateAdd() {
+ [Test]
+ public void DateAdd()
+ {
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));
+ Assertion.AssertEquals("#DA01", dtNow.AddYears(1), DateAndTime.DateAdd(DateInterval.Year, 1, dtNow));
+ Assertion.AssertEquals("#DA02", dtNow.AddYears(-1), DateAndTime.DateAdd("yyyy", -1, dtNow));
bool caughtException = false;
@@ -125,38 +132,38 @@
DateAndTime.DateAdd("foo", 1, dtNow);
}
catch (Exception e) {
- AssertEquals("#DA03", e.GetType(), typeof(ArgumentException));
+ Assertion.AssertEquals("#DA03", e.GetType(), typeof(ArgumentException));
caughtException = true;
}
- AssertEquals("#DA04", caughtException, true);
+ Assertion.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));
+ Assertion.AssertEquals("#DA05", dtNow.AddMonths(6), DateAndTime.DateAdd(DateInterval.Quarter, 2, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA07", dtNow.AddMonths(3), DateAndTime.DateAdd(DateInterval.Month, 3, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA09", dtNow.AddDays(28), DateAndTime.DateAdd(DateInterval.WeekOfYear, 4, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA11", dtNow.AddDays(5), DateAndTime.DateAdd(DateInterval.Weekday, 5, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA13", dtNow.AddDays(6), DateAndTime.DateAdd(DateInterval.DayOfYear, 6, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA15", dtNow.AddDays(7), DateAndTime.DateAdd(DateInterval.Day, 7, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA17", dtNow.AddHours(8), DateAndTime.DateAdd(DateInterval.Hour, 8, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA19", dtNow.AddMinutes(9), DateAndTime.DateAdd(DateInterval.Minute, 9, dtNow));
+ Assertion.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));
+ Assertion.AssertEquals("#DA21", dtNow.AddSeconds(10), DateAndTime.DateAdd(DateInterval.Second, 10, dtNow));
+ Assertion.AssertEquals("#DA22", dtNow.AddSeconds(-10), DateAndTime.DateAdd("s", -10, dtNow));
caughtException = false;
@@ -165,35 +172,37 @@
}
catch (Exception e) {
caughtException = true;
- AssertEquals("#DA23", e.GetType(), typeof(Exception));
+ Assertion.AssertEquals("#DA23", e.GetType(), typeof(Exception));
}
- // AssertEquals("#DA24", caughtException, true);
+ // Assertion.AssertEquals("#DA24", caughtException, true);
}
- public void TestDateDiff () {
+ [Test]
+ public void DateDiff ()
+ {
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));
+ Assertion.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);
+ Assertion.AssertEquals("#DD02", 1L, diff);
diff = DateAndTime.DateDiff(DateInterval.Quarter, dtDec31, dtJan1, FirstDayOfWeek.System, FirstWeekOfYear.System);
- AssertEquals("#DD03", 1L, diff);
+ Assertion.AssertEquals("#DD03", 1L, diff);
diff = DateAndTime.DateDiff(DateInterval.Month, dtDec31, dtJan1, FirstDayOfWeek.System, FirstWeekOfYear.System);
- AssertEquals("#DD04", 1L, diff);
+ Assertion.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
@@ -201,61 +210,69 @@
long WD = DateAndTime.DateDiff(DateInterval.Weekday, dtJan4, dtJan9, FirstDayOfWeek.System, FirstWeekOfYear.System);
- AssertEquals ("#DD05", 0L, WD);
+ Assertion.AssertEquals ("#DD05", 0L, WD);
long WY = DateAndTime.DateDiff(DateInterval.WeekOfYear, dtJan4, dtJan9, FirstDayOfWeek.System, FirstWeekOfYear.System);
- AssertEquals ("#DD06", 1L, WY);
+ Assertion.AssertEquals ("#DD06", 1L, WY);
}
- public void TestDatePart () {
+ [Test]
+ public void DatePart ()
+ {
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));
+ Assertion.AssertEquals("#DP01", 2001, DateAndTime.DatePart(DateInterval.Year, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ Assertion.AssertEquals("#DP02", 1, DateAndTime.DatePart(DateInterval.Quarter, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ Assertion.AssertEquals("#DP03", 1, DateAndTime.DatePart(DateInterval.Month, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ Assertion.AssertEquals("#DP04", 1, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP05", 53, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.FirstFullWeek));
+ Assertion.AssertEquals("#DP06", 1, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.Jan1));
+ Assertion.AssertEquals("#DP07", 1, DateAndTime.DatePart(DateInterval.WeekOfYear, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.System));
+ Assertion.AssertEquals("#DP08", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Friday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP09", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Saturday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP10", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Sunday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP11", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP12", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Tuesday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP13", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Wednesday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP14", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.Thursday, FirstWeekOfYear.FirstFourDays));
+ Assertion.AssertEquals("#DP15", 5, DateAndTime.DatePart(DateInterval.Weekday, dtJan4, FirstDayOfWeek.System, FirstWeekOfYear.FirstFourDays));
}
- public void TestDateSerial () {
+ [Test]
+ public void DateSerial ()
+ {
DateTime dtJan4 = new DateTime(2001, 1, 4);
DateTime dtSerial = DateAndTime.DateSerial(2001, 1, 4);
- AssertEquals("#DS01", dtJan4, dtSerial);
+ Assertion.AssertEquals("#DS01", dtJan4, dtSerial);
}
- public void TestTimeSerial () {
+ [Test]
+ public void TimeSerial ()
+ {
bool caughtException = false;
try {
DateAndTime.TimeSerial(0, -1440, -1);
}
catch (Exception e) {
- AssertEquals("#TS01", e.GetType(), typeof(ArgumentOutOfRangeException));
+ Assertion.AssertEquals("#TS01", e.GetType(), typeof(ArgumentOutOfRangeException));
caughtException = true;
}
- AssertEquals("#TS02", true, caughtException);
+ Assertion.AssertEquals("#TS02", true, caughtException);
- AssertEquals("#TS03", new DateTime(1, 1, 1, 1, 1, 1), DateAndTime.TimeSerial(1, 1, 1));
+ Assertion.AssertEquals("#TS03", new DateTime(1, 1, 1, 1, 1, 1), DateAndTime.TimeSerial(1, 1, 1));
}
- public void TestDateValue () {
+ [Test]
+ public void DateValue ()
+ {
try {
DateAndTime.DateValue("This is not a date.");
}
@@ -263,12 +280,14 @@
/* do nothing. this is what we expect */
}
catch (Exception e) {
- Fail ("Unexpected exception:" + e);
+ Assertion.Fail ("Unexpected exception:" + e);
}
- AssertEquals("#DV03", new DateTime(1969, 2, 12), DateAndTime.DateValue("February 12, 1969"));
+ Assertion.AssertEquals("#DV03", new DateTime(1969, 2, 12), DateAndTime.DateValue("February 12, 1969"));
}
- public void TestTimeValue () {
+ [Test]
+ public void TimeValue ()
+ {
try {
DateAndTime.TimeValue("This is not a time.");
}
@@ -276,51 +295,67 @@
/* do nothing. this is what we expect */
}
catch (Exception e) {
- Fail ("Unexpected exception:" + e);
+ Assertion.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"));
+ Assertion.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 () {
+ [Test]
+ public void Year ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#Y01", jan1.Year, DateAndTime.Year(jan1));
+ Assertion.AssertEquals("#Y01", jan1.Year, DateAndTime.Year(jan1));
}
- public void TestMonth () {
+ [Test]
+ public void Month ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#MO01", jan1.Month, DateAndTime.Month(jan1));
+ Assertion.AssertEquals("#MO01", jan1.Month, DateAndTime.Month(jan1));
}
- public void TestDay () {
+ [Test]
+ public void Day ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#D01", jan1.Day, DateAndTime.Day(jan1));
+ Assertion.AssertEquals("#D01", jan1.Day, DateAndTime.Day(jan1));
}
- public void TestHour () {
+ [Test]
+ public void Hour ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#H01", jan1.Hour, DateAndTime.Hour(jan1));
+ Assertion.AssertEquals("#H01", jan1.Hour, DateAndTime.Hour(jan1));
}
- public void TestMinute () {
+ [Test]
+ public void Minute ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#MI01", jan1.Minute, DateAndTime.Minute(jan1));
+ Assertion.AssertEquals("#MI01", jan1.Minute, DateAndTime.Minute(jan1));
}
- public void TestSecond () {
+ [Test]
+ public void Second ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#S01", jan1.Second, DateAndTime.Second(jan1));
+ Assertion.AssertEquals("#S01", jan1.Second, DateAndTime.Second(jan1));
}
- public void TestWeekday () {
+ [Test]
+ public void Weekday ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#W01", (int)jan1.DayOfWeek + 1, DateAndTime.Weekday(jan1, FirstDayOfWeek.System));
+ Assertion.AssertEquals("#W01", (int)jan1.DayOfWeek + 1, DateAndTime.Weekday(jan1, FirstDayOfWeek.System));
}
- public void TestMonthName () {
+ [Test]
+ public void MonthName ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#MN01", CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(jan1.Month),
+ Assertion.AssertEquals("#MN01", CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(jan1.Month),
DateAndTime.MonthName(jan1.Month, true));
- AssertEquals("#MN02", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(jan1.Month),
+ Assertion.AssertEquals("#MN02", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(jan1.Month),
DateAndTime.MonthName(jan1.Month, false));
bool caughtException = false;
@@ -329,10 +364,10 @@
DateAndTime.MonthName(0, false);
}
catch (Exception e) {
- AssertEquals("#MN03", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#MN03", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#MN04", true, caughtException);
+ Assertion.AssertEquals("#MN04", true, caughtException);
caughtException = false;
@@ -340,19 +375,21 @@
DateAndTime.MonthName(14, false);
}
catch (Exception e) {
- AssertEquals("#MN05", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#MN05", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#MN06", true, caughtException);
+ Assertion.AssertEquals("#MN06", true, caughtException);
- //AssertEquals("#MN07", "", DateAndTime.MonthName(13, false));
+ //Assertion.AssertEquals("#MN07", "", DateAndTime.MonthName(13, false));
}
- public void TestWeekdayName () {
+ [Test]
+ public void WeekdayName ()
+ {
DateTime jan1 = new DateTime(2001, 1, 1, 1, 1, 1);
- AssertEquals("#WN01", "Tue",
+ Assertion.AssertEquals("#WN01", "Tue",
DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, true, FirstDayOfWeek.System));
- AssertEquals("#WN02", "Tuesday",
+ Assertion.AssertEquals("#WN02", "Tuesday",
DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, false, FirstDayOfWeek.System));
bool caughtException = false;
@@ -361,10 +398,10 @@
DateAndTime.WeekdayName(0, false, FirstDayOfWeek.System);
}
catch (Exception e) {
- AssertEquals("#WN03", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#WN03", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#WN04", true, caughtException);
+ Assertion.AssertEquals("#WN04", true, caughtException);
caughtException = false;
@@ -372,17 +409,12 @@
DateAndTime.WeekdayName(8, false, FirstDayOfWeek.System);
}
catch (Exception e) {
- AssertEquals("#WN05", typeof(ArgumentException), e.GetType());
+ Assertion.AssertEquals("#WN05", typeof(ArgumentException), e.GetType());
caughtException = true;
}
- AssertEquals("#WN06", true, caughtException);
+ Assertion.AssertEquals("#WN06", true, caughtException);
- AssertEquals("#WN07", "Tuesday", DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, false, FirstDayOfWeek.System));
+ Assertion.AssertEquals("#WN07", "Tuesday", DateAndTime.WeekdayName((int)jan1.DayOfWeek + 1, false, FirstDayOfWeek.System));
}
-
-
-
-
-
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile.gnu
Type: text/x-makefile
Size: 629 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20030311/e63dc326/attachment.bin
-------------- next part --------------
CollectionTest.cs
ConversionTest.cs
DateAndTimeTest.cs
More information about the Mono-devel-list
mailing list