⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 informationtests.cs

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 CS
📖 第 1 页 / 共 2 页
字号:
		{			byte oDT1 = 1; 			short oDT2 = 1; 			int oDT3 = 1; 			long oDT4 = 1000; 			float oDT5 = 1; 			double oDT6 = 2.2; 			decimal oDT7 = 1000; 			string oDT8 = "abc"; 			object oDT9 = oDT1; 			bool oDT10 = true; 			char oDT11 = 'c';			System.DateTime oDT12 = System.DateTime.Parse("5/31/1993");			string oDT13 = "";			string oDT14 = null;			Assert.AreEqual(false,Information.IsReference(oDT1));			Assert.AreEqual(false,Information.IsReference(oDT2));			Assert.AreEqual(false,Information.IsReference(oDT3));			Assert.AreEqual(false,Information.IsReference(oDT4));			Assert.AreEqual(false,Information.IsReference(oDT5));			Assert.AreEqual(false,Information.IsReference(oDT6));			Assert.AreEqual(false,Information.IsReference(oDT7));			Assert.AreEqual(true,Information.IsReference(oDT8));			Assert.AreEqual(false,Information.IsReference(oDT9));			Assert.AreEqual(false,Information.IsReference(oDT10));			Assert.AreEqual(false,Information.IsReference(oDT11));			Assert.AreEqual(false,Information.IsReference(oDT12));			Assert.AreEqual(true,Information.IsReference(oDT13));			Assert.AreEqual(true,Information.IsReference(oDT14));		}		[Test]		public void IsReference_3()		{			test_cls tmpobj1 = new test_cls();			Itest_cls Itest = null;			Assert.AreEqual(true,Information.IsReference(tmpobj1));			Assert.AreEqual(true,Information.IsReference(Itest));					}		#endregion		#region SystemTypeName tests		[Test]		public void SystemTypeName_1()		{			Assert.AreEqual("System.Boolean",Information.SystemTypeName("BOolean"));			Assert.AreEqual("System.Byte",Information.SystemTypeName("bYte"));			Assert.AreEqual("System.Int16",Information.SystemTypeName("Short"));			Assert.AreEqual("System.Int32",Information.SystemTypeName("Integer"));			Assert.AreEqual("System.Char",Information.SystemTypeName("char"));			Assert.AreEqual("System.Single",Information.SystemTypeName("single"));			Assert.AreEqual("System.Double",Information.SystemTypeName("double"));			Assert.AreEqual("System.String",Information.SystemTypeName("StRing"));			Assert.AreEqual("System.DateTime",Information.SystemTypeName("DATE")); 			Assert.AreEqual("System.Decimal",Information.SystemTypeName("decimal"));			Assert.AreEqual("System.Object",Information.SystemTypeName("Object"));			Assert.AreEqual("System.DateTime",Information.SystemTypeName("date"));			Assert.AreEqual("System.Int64",Information.SystemTypeName("Long"));			Assert.AreEqual(null,Information.SystemTypeName("MUKY")); 		}		#endregion		#region IsDate tests		[Test]		public void IsDate_1()		{			DateTime tmpDate = DateTime.Parse("5/31/1993");			String tmpStr = "RRRR";			object tmpObj = null;			Assert.AreEqual(true,Information.IsDate(tmpDate));			Assert.AreEqual(false,Information.IsDate(tmpStr));			Assert.AreEqual(true,Information.IsDate("February 12, 1969"));			Assert.AreEqual(false,Information.IsDate(30));			Assert.AreEqual(false,Information.IsDate(tmpObj));		}		[Test]		public void IsDate_2()		{			byte oDT1 = 1; 			short oDT2 = 1; 			int oDT3 = 1; 			long oDT4 = 1000; 			float oDT5 = 1; 			double oDT6 = 2.2; 			decimal oDT7 = 1000; 			string oDT8 = "abc"; 			object oDT9 = null; 			bool oDT10 = true; 			char oDT11 = 'c';			Assert.AreEqual(false,Information.IsDate(oDT1));			Assert.AreEqual(false,Information.IsDate(oDT2));			Assert.AreEqual(false,Information.IsDate(oDT3));			Assert.AreEqual(false,Information.IsDate(oDT4));			Assert.AreEqual(false,Information.IsDate(oDT5));			Assert.AreEqual(false,Information.IsDate(oDT6));			Assert.AreEqual(false,Information.IsDate(oDT7));			Assert.AreEqual(false,Information.IsDate(oDT8));			Assert.AreEqual(false,Information.IsDate(oDT9));			Assert.AreEqual(false,Information.IsDate(oDT10));			Assert.AreEqual(false,Information.IsDate(oDT11));			}		#endregion		#region IsArray tests		[Test]		public void IsArray_1()		{			String tmpStr = "RRRR";			object tmpObj = null;			int[] tmpArr = new int [2];            tmpArr[1] = 2;			byte[] oDT1 = new byte[2]; 			short[] oDT2 = new short[2]; 			int[] oDT3 = new int[2]; 			long[] oDT4 = new long[2]; 			float[] oDT5 = new float[2]; 			double[] oDT6 = new double[2]; 			decimal[] oDT7 = new decimal[2]; 			string[] oDT8 = new string[2]; 			object[] oDT9 = new object[2]; 			bool[] oDT10 = new bool[2]; 			char[] oDT11 = new char[2]; 			System.DateTime[] oDT12 = new System.DateTime[2];			Assert.AreEqual(false,Information.IsArray(tmpStr));			Assert.AreEqual(false,Information.IsArray("February 12, 1969"));			Assert.AreEqual(false,Information.IsArray(30));			Assert.AreEqual(false,Information.IsArray(tmpObj));			Assert.AreEqual(true,Information.IsArray(tmpArr));			Assert.AreEqual(true,Information.IsArray(oDT1));			Assert.AreEqual(true,Information.IsArray(oDT2));			Assert.AreEqual(true,Information.IsArray(oDT3));			Assert.AreEqual(true,Information.IsArray(oDT4));			Assert.AreEqual(true,Information.IsArray(oDT5));			Assert.AreEqual(true,Information.IsArray(oDT6));			Assert.AreEqual(true,Information.IsArray(oDT7));			Assert.AreEqual(true,Information.IsArray(oDT8));			Assert.AreEqual(true,Information.IsArray(oDT9));			Assert.AreEqual(true,Information.IsArray(oDT10));			Assert.AreEqual(true,Information.IsArray(oDT11));			Assert.AreEqual(true,Information.IsArray(oDT12));		}		[Test]		public void IsArray_2()		{						byte oDT1 = 1; 			short oDT2 = 1; 			int oDT3 = 1; 			long oDT4 = 1000; 			float oDT5 = 22; 			double oDT6 = 2.2; 			decimal oDT7 = 1000; 			string oDT8 = "abc"; 			object oDT9 = null; 			bool oDT10 = true; 			char oDT11 = 'c'; 			System.DateTime oDT12 = System.DateTime.Parse("5/31/1993");			Assert.AreEqual(false,Information.IsArray(oDT1));			Assert.AreEqual(false,Information.IsArray(oDT2));			Assert.AreEqual(false,Information.IsArray(oDT3));			Assert.AreEqual(false,Information.IsArray(oDT4));			Assert.AreEqual(false,Information.IsArray(oDT5));			Assert.AreEqual(false,Information.IsArray(oDT6));			Assert.AreEqual(false,Information.IsArray(oDT7));			Assert.AreEqual(false,Information.IsArray(oDT8));			Assert.AreEqual(false,Information.IsArray(oDT9));			Assert.AreEqual(false,Information.IsArray(oDT10));			Assert.AreEqual(false,Information.IsArray(oDT11));			Assert.AreEqual(false,Information.IsArray(oDT12));		}		[Test]		public void IsArray_3()		{			test_cls[] oDT1 = new test_cls[2];            Assert.AreEqual(true,Information.IsArray(oDT1));		}		internal class test_cls		{			private int a;		};		#endregion		#region TypeName tests		[Test]		public void TypeName_1()		{			int b = 12;			int[] a = new int[3];			byte vbyte = 1;			a[0] = 222;			short shr = 2;			double dbl = 12222;			System.Single tmpsngl = 1;			decimal dcm = 22;			object obj = null;			long tmplong = 11111;            DBNull testBDNull = DBNull.Value;			string tmpStr = "Test Str";			System.DateTime tmpDate = System.DateTime.Parse("5/31/1993");			bool tmpbool = true;			test_cls tmp_class = new test_cls();			Assert.AreEqual("String",Information.TypeName(tmpStr));			Assert.AreEqual("Integer()",Information.TypeName(a));			Assert.AreEqual("Byte",Information.TypeName(vbyte));			Assert.AreEqual("Integer",Information.TypeName(b));			Assert.AreEqual("DBNull",Information.TypeName(testBDNull));			Assert.AreEqual("Double",Information.TypeName(dbl));			Assert.AreEqual("Short",Information.TypeName(shr));			Assert.AreEqual("Single",Information.TypeName(tmpsngl));			Assert.AreEqual("Char",Information.TypeName('c'));			Assert.AreEqual("Decimal",Information.TypeName(dcm));			Assert.AreEqual("Nothing",Information.TypeName(obj)); 			Assert.AreEqual("Date",Information.TypeName(tmpDate)); 			Assert.AreEqual("Long",Information.TypeName(tmplong));			Assert.AreEqual("Boolean",Information.TypeName(tmpbool));			Assert.AreEqual("test_cls",Information.TypeName(tmp_class));		}		#endregion		#region VbTypeName tests		[Test]		public void VbTypeName_1()		{			Assert.AreEqual("Integer",Information.VbTypeName("System.Int32"));			Assert.AreEqual("Long",Information.VbTypeName("Int64"));			Assert.AreEqual("Integer",Information.VbTypeName("Int32"));			Assert.AreEqual("Boolean",Information.VbTypeName("boolean"));			Assert.AreEqual("Short",Information.VbTypeName("Int16"));			Assert.AreEqual("Double",Information.VbTypeName("double"));			Assert.AreEqual("Decimal",Information.VbTypeName("decimal"));			Assert.AreEqual("Decimal",Information.VbTypeName("System.Decimal"));			Assert.AreEqual("Object",Information.VbTypeName("System.Object"));			Assert.AreEqual("Byte",Information.VbTypeName("System.Byte"));			Assert.AreEqual("String",Information.VbTypeName("System.String"));			Assert.AreEqual("Char",Information.VbTypeName("system.char"));			Assert.AreEqual("Date",Information.VbTypeName("System.DateTime"));			Assert.AreEqual("Single",Information.VbTypeName("system.Single"));			Assert.AreEqual("Object",Information.VbTypeName("objEct")); 			Assert.AreEqual(null,Information.VbTypeName("BlaBla")); 		}		#endregion		#region VarType tests		[Test]		public void VarType_1()		{			bool b1 = true;			long l1 = 1000000;			VariantType tmpVartype = VariantType.Integer;			object tmpObj = null;			DateTime tmpDate = DateTime.Parse("5/31/1993");			object tmpDBnullobj = System.DBNull.Value;			int[] tmpIntArr = new int []{1,2,3} ;			string[] tmpStrArr = new string [2];			MyStruct tmpStruct = new MyStruct();			string strstr = "test";			byte tmpByte = 1;			short tmpShort = 2;			int tmpInt = 22;			Single tmpSingle = 2;			double tmpDouble = 222.2;			decimal tmpDec = 222;			int[,] int_arr = new int[,] { {1, 2}, {3, 4}, {5, 6} };			Assert.AreEqual(VariantType.String, Information.VarType(strstr));			Assert.AreEqual(VariantType.UserDefinedType, Information.VarType(tmpStruct));			Assert.AreEqual(VariantType.Null, Information.VarType(tmpDBnullobj));			Assert.AreEqual(VariantType.Array | VariantType.Integer, Information.VarType(int_arr),"VariantType.Array | VariantType.Integer");			// Information.VarType doesn`t return what docs says: int[,] should returns VariantType.Array | VariantType.Object 			// but returns VariantType.Array | VariantType.Integer SO this is what we implement too.			Assert.AreEqual(VariantType.Array | VariantType.Integer, Information.VarType(tmpIntArr),"VariantType.Array | VariantType.Integer 2D");			Assert.AreEqual(VariantType.Array | VariantType.String, Information.VarType(tmpStrArr),"VariantType.Array | VariantType.String");			Assert.AreEqual(VariantType.Date, Information.VarType(tmpDate));			Assert.AreEqual(VariantType.Boolean, Information.VarType(b1));			Assert.AreEqual(VariantType.Long, Information.VarType(l1));			Assert.AreEqual(VariantType.Byte, Information.VarType(tmpByte));			Assert.AreEqual(VariantType.Short, Information.VarType(tmpShort));			Assert.AreEqual(VariantType.Double, Information.VarType(tmpDouble));			Assert.AreEqual(VariantType.Single, Information.VarType(tmpSingle));			Assert.AreEqual(VariantType.Decimal, Information.VarType(tmpDec));			Assert.AreEqual(VariantType.Integer, Information.VarType(tmpInt),"Call VarType(tmpInt)");			Assert.AreEqual(VariantType.Integer, Information.VarType(tmpVartype),"Call VarType(tmpVartype)");			Assert.AreEqual(VariantType.Object, Information.VarType(tmpObj));			Assert.AreEqual(VariantType.Char, Information.VarType('c'));		}		[Test]		public void VarType_2()		{			try			{				int zero; 				int result; 				zero = 0; 				result = 8 / zero;			}			catch(Exception ex)			{				Assert.AreEqual(VariantType.Error, Information.VarType(ex));			}		}		internal struct MyStruct 		{ 			int Tel; 		}		#endregion		#region QBColor tests		[Test]		public void QBColor_1()		{			int i; 			decimal d = 0; 			for (i = 0; i <= 15; i++) 			{ 				d = d + Information.QBColor(i); 			} 			Assert.AreEqual(113427132,d);		}		[Test]		[ExpectedException (typeof(ArgumentException))]		public void QBColor_2()		{			int i;			i = Information.QBColor(17);		}		[Test]		[ExpectedException (typeof(ArgumentException))]		public void QBColor_3()		{			int i;			i = Information.QBColor(-1);		}		#endregion	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -