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

📄 informationtests.cs

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 CS
📖 第 1 页 / 共 2 页
字号:
// InformationTests.cs - NUnit Test Cases for Microsoft.VisualBasic.Information //// Guy Cohen (guyc@mainsoft.com)// // // Copyright (c) 2002-2006 Mainsoft Corporation.// Copyright (C) 2004 Novell, Inc (http://www.novell.com)//// Permission is hereby granted, free of charge, to any person obtaining// a copy of this software and associated documentation files (the// "Software"), to deal in the Software without restriction, including// without limitation the rights to use, copy, modify, merge, publish,// distribute, sublicense, and/or sell copies of the Software, and to// permit persons to whom the Software is furnished to do so, subject to// the following conditions:// // The above copyright notice and this permission notice shall be// included in all copies or substantial portions of the Software.// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.//using NUnit.Framework;using System;using System.IO;using System.Collections;using Microsoft.VisualBasic;namespace MonoTests.Microsoft_VisualBasic{	[TestFixture]	public class InformationTests	{		public InformationTests()		{		}		[SetUp]		public void GetReady() 		{		}		[TearDown]		public void Clean() 		{		}			#region IsError tests		[Test]		public void IsError_1()		{			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.IsError(oDT1));			Assert.AreEqual(false,Information.IsError(oDT2));			Assert.AreEqual(false,Information.IsError(oDT3));			Assert.AreEqual(false,Information.IsError(oDT4));			Assert.AreEqual(false,Information.IsError(oDT5));			Assert.AreEqual(false,Information.IsError(oDT6));			Assert.AreEqual(false,Information.IsError(oDT7));			Assert.AreEqual(false,Information.IsError(oDT8));			Assert.AreEqual(false,Information.IsError(oDT9));			Assert.AreEqual(false,Information.IsError(oDT10));			Assert.AreEqual(false,Information.IsError(oDT11));			Assert.AreEqual(false,Information.IsError(oDT12));		}		[Test]		public void IsError_2()		{						string BadArg = "BAD ARGS"; 			object ReturnVal = new System.ArgumentOutOfRangeException(BadArg); 			object o1;			o1 = new ArgumentOutOfRangeException();			Assert.AreEqual(true,Information.IsError(o1));			Assert.AreEqual(true,Information.IsError(ReturnVal));		}		#endregion		#region IsNothing tests		[Test]		public void IsNothing_1()		{			object o1;						o1 = "test";			Assert.AreEqual(false,Information.IsNothing(o1));			o1 = null;			Assert.AreEqual(true,Information.IsNothing(o1));		}		[Test]		public void IsNothing_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.IsNothing(oDT1));			Assert.AreEqual(false,Information.IsNothing(oDT2));			Assert.AreEqual(false,Information.IsNothing(oDT3));			Assert.AreEqual(false,Information.IsNothing(oDT4));			Assert.AreEqual(false,Information.IsNothing(oDT5));			Assert.AreEqual(false,Information.IsNothing(oDT6));			Assert.AreEqual(false,Information.IsNothing(oDT7));			Assert.AreEqual(false,Information.IsNothing(oDT8));			Assert.AreEqual(true,Information.IsNothing(oDT9));			Assert.AreEqual(false,Information.IsNothing(oDT10));			Assert.AreEqual(false,Information.IsNothing(oDT11));			Assert.AreEqual(false,Information.IsNothing(oDT12));		}		[Test]		public void IsNothing_4()		{			test_nothing tmp_class = new test_nothing();			Assert.AreEqual(false,Information.IsNothing(tmp_class));		}		internal class test_nothing		{		}		#endregion		#region RGB tests		[Test]		public void RGB_1()		{			Assert.AreEqual(0,Information.RGB(0,0,0));			Assert.AreEqual(6579300,Information.RGB(100,100,100));			Assert.AreEqual(13158600,Information.RGB(200,200,200));			Assert.AreEqual(16777215,Information.RGB(255,255,290));		}		[Test]		[ExpectedException (typeof(ArgumentException))]		public void RGB_2()		{			int i;			i = Information.RGB(50,12,-1);		}		[Test]		[ExpectedException (typeof(ArgumentException))]		public void RGB_3()		{			int i;			i = Information.RGB(50,-1,1);		}		[Test]		[ExpectedException (typeof(ArgumentException))]		public void RGB_4()		{			int i;			i = Information.RGB(-1,122,11);		}		[Test]		public void RGB_5()		{			decimal d = 0; 			for (int i = 0; i <= 255; i += 255) 			{ 				for (int j = 0; j <= 255; j += 255) 				{ 					for (int k = 0; k <= 255; k += 255) 					{ 						d = d + Information.RGB(i, j, k); 					} 				} 			} 			Assert.AreEqual(67108860,d);				}		[Test]		public void RGB_6()		{			// greater than 255, 255 is used			decimal resA1, resA2, resB1, resB2, resC1, resC2;			resA1 = Information.RGB(255, 0, 0); 			resA2 = Information.RGB(256, 0, 0); 			 			resB1 = Information.RGB(0, 255, 0); 			resB2 = Information.RGB(0, 256, 0); 						resC1 = Information.RGB(0, 0, 255); 			resC2 = Information.RGB(0, 0, 256); 						Assert.AreEqual(resA1,resA2);			Assert.AreEqual(resB1,resB2);			Assert.AreEqual(resC1,resC2);					}		#endregion		#region IsNumeric tests		[Test]		public void IsNumeric_1()		{			if (Helper.OnMono)				Assert.Ignore ("Buggy mono: #81777");				object tmpobj1 = "43";			object tmpobj2 = "343 TEST";			Assert.AreEqual(false,Information.IsNumeric("20 werwer"));			Assert.AreEqual(true,Information.IsNumeric("2020"));			Assert.AreEqual(true,Information.IsNumeric("222,34"));			Assert.AreEqual(true,Information.IsNumeric(".45"));			Assert.AreEqual(true,Information.IsNumeric(-0.3));			Assert.AreEqual(false,Information.IsNumeric("14.33.33"));			Assert.AreEqual(true,Information.IsNumeric(tmpobj1));			Assert.AreEqual(false,Information.IsNumeric(tmpobj2));			}		[Test]		public void IsNumeric_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 = "";			Assert.AreEqual(true,Information.IsNumeric(oDT1),"oDT1");			Assert.AreEqual(true,Information.IsNumeric(oDT2),"oDT2");			Assert.AreEqual(true,Information.IsNumeric(oDT3),"oDT3");			Assert.AreEqual(true,Information.IsNumeric(oDT4),"oDT4");			Assert.AreEqual(true,Information.IsNumeric(oDT5),"oDT5");			Assert.AreEqual(true,Information.IsNumeric(oDT6));			Assert.AreEqual(true,Information.IsNumeric(oDT7));			Assert.AreEqual(false,Information.IsNumeric(oDT8));			Assert.AreEqual(true,Information.IsNumeric(oDT9));			Assert.AreEqual(true,Information.IsNumeric(oDT10));			Assert.AreEqual(false,Information.IsNumeric(oDT11));			Assert.AreEqual(false,Information.IsNumeric(oDT12));			Assert.AreEqual(false,Information.IsNumeric(oDT13));			}		[Test]		public void IsNumeric_3()		{			test_cls tmpobj1 = new test_cls();			Itest_cls Itest = null;			Assert.AreEqual(false,Information.IsNumeric(tmpobj1));			Assert.AreEqual(false,Information.IsNumeric(Itest));			}		internal interface Itest_cls		{		};		#endregion		#region IsDBNull tests		[Test]		public void IsDBNull_1()		{			object tmpobj = null;			object tmpDBnullobj = System.DBNull.Value;			Assert.AreEqual(false,Information.IsDBNull("werwer"));			Assert.AreEqual(false,Information.IsDBNull(""));			Assert.AreEqual(false,Information.IsDBNull(tmpobj));			Assert.AreEqual(true,Information.IsDBNull(tmpDBnullobj));			}				[Test]		public void IsDBNull_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.IsDBNull(oDT1));			Assert.AreEqual(false,Information.IsDBNull(oDT2));			Assert.AreEqual(false,Information.IsDBNull(oDT3));			Assert.AreEqual(false,Information.IsDBNull(oDT4));			Assert.AreEqual(false,Information.IsDBNull(oDT5));			Assert.AreEqual(false,Information.IsDBNull(oDT6));			Assert.AreEqual(false,Information.IsDBNull(oDT7));			Assert.AreEqual(false,Information.IsDBNull(oDT8));			Assert.AreEqual(false,Information.IsDBNull(oDT9));			Assert.AreEqual(false,Information.IsDBNull(oDT10));			Assert.AreEqual(false,Information.IsDBNull(oDT11));			Assert.AreEqual(false,Information.IsDBNull(oDT12));		}		#endregion		#region IsReference tests		[Test]		public void IsReference_1()		{			int i = 3;			String tempStr = "TEST STRING";			Object tmpObj = null;			bool[] bArr = new bool[2];			Assert.AreEqual(false,Information.IsReference(i));			Assert.AreEqual(true,Information.IsReference(tempStr));			Assert.AreEqual(true,Information.IsReference(bArr));			Assert.AreEqual(true,Information.IsReference(tmpObj)); 			Assert.AreEqual(false,Information.IsReference(-0.3));		}		[Test]		public void IsReference_2()

⌨️ 快捷键说明

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