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

📄 collectiontests.cs

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 CS
📖 第 1 页 / 共 4 页
字号:
		[Test]		public void GetEnumerator_4()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			long o4 = 1000;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			en.MoveNext();			col.Add(o4,null,null,null);			Assert.AreEqual(o1,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o2,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o3,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o4,en.Current);			Assert.IsFalse(en.MoveNext());		}		[Test]		public void GetEnumerator_5()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			long o4 = 1000;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			en.MoveNext();			col.Add(o4,null,1,null);			Assert.AreEqual(o1,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o2,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o3,en.Current);			Assert.IsFalse(en.MoveNext());			Assert.AreEqual(null,en.Current);			col.Add(o4,null,null,null);#if NET_2_0			Assert.AreEqual(null,en.Current);#else			Assert.AreEqual(o4,en.Current);#endif			Assert.IsFalse(en.MoveNext());		}		[Test]		public void GetEnumerator_10()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			long o4 = 1000;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			col.Add(o4,null,1,null);			en.MoveNext();			Assert.AreEqual(o4,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o1,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o2,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o3,en.Current);			Assert.IsFalse(en.MoveNext());			Assert.AreEqual(null,en.Current);			col.Add(o4,null,null,null);#if NET_2_0			Assert.AreEqual(null,en.Current);#else			Assert.AreEqual(o4,en.Current);#endif			Assert.IsFalse(en.MoveNext());		}		[Test]#if !NET_2_0		[ExpectedException(typeof(IndexOutOfRangeException))]#endif		public void GetEnumerator_11()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o1,en.Current);			col.Remove(1);						object o = en.Current;			Assert.AreEqual (o1, o, "#01");		}		[Test]		public void GetEnumerator_12()		{			Collection col = new Collection();			string s1 = "e";			string s2 = "g";			string s3 = "a";			string s4 = "f";			col.Add(s1,null,null,null);			col.Add(s2,null,null,null);			col.Add(s3,null,null,null);			IEnumerator en = col.GetEnumerator();			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(s1,en.Current);			col.Remove(1);						Assert.IsTrue(en.MoveNext());			Assert.AreEqual(s2,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(s3,en.Current);			Assert.IsFalse(en.MoveNext());			col.Add(s4,null,null,null);#if NET_2_0			Assert.AreEqual(null,en.Current);#else			Assert.AreEqual(s4,en.Current);#endif			Assert.IsFalse(en.MoveNext());		}		[Test]		public void GetEnumerator_13()		{			Collection col = new Collection();			string s1 = "e";			string s2 = "g";			string s3 = "a";			string s4 = "f";			string s5 = "q";			col.Add(s1,null,null,null);			col.Add(s2,null,null,null);						IEnumerator en = col.GetEnumerator();			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(s1,en.Current);					Assert.IsTrue(en.MoveNext());			Assert.AreEqual(s2,en.Current);			Assert.IsFalse(en.MoveNext());			Assert.AreEqual(null,en.Current);			col.Add(s3,null,null,null);#if NET_2_0			Assert.AreEqual(null,en.Current);#else			Assert.AreEqual(s3,en.Current);#endif			col.Add(s4,null,null,null);			col.Add(s5,null,null,null);			#if !NET_2_0			Assert.IsTrue(en.MoveNext());			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(s5,en.Current);#endif			Assert.IsFalse(en.MoveNext());		}		[Test]		public void GetEnumerator_6()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			en.MoveNext();			col.Remove(3);			Assert.AreEqual(o1,en.Current);			Assert.IsTrue(en.MoveNext());			Assert.AreEqual(o2,en.Current);			Assert.IsFalse(en.MoveNext());		}		[Test]#if !NET_2_0		[ExpectedException(typeof(IndexOutOfRangeException))]#endif		public void GetEnumerator_7()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			en.MoveNext();			col.Remove(1);			object o = en.Current;		}		[Test]		public void GetEnumerator_8()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			en.MoveNext();			col.Remove(3);			col.Remove(2);			Assert.AreEqual(o1,en.Current);			Assert.IsFalse(en.MoveNext());		}		[Test]		public void GetEnumerator_9()		{			Collection col = new Collection();			Byte o1 = 1;			short o2 = 1;			int o3 = 1;			col.Add(o1,null,null,null);			col.Add(o2,null,null,null);			col.Add(o3,null,null,null);			IEnumerator en = col.GetEnumerator();			Assert.IsTrue(en.MoveNext());			Assert.IsTrue(en.MoveNext());			Assert.IsTrue(en.MoveNext());			Assert.IsFalse(en.MoveNext());			Assert.AreEqual(null,en.Current);			Assert.IsFalse(en.MoveNext());			Assert.AreEqual(null,en.Current);			Assert.IsFalse(en.MoveNext());								}		// Test GetEnumerator method		[Test]		public void GetEnumerator ()		{			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 ();			Assert.IsNotNull (e, "#GE01");			while (e.MoveNext ()) 			{				Assert.AreEqual (o[i], e.Current, "#GE02." + i.ToString ());				i++;			}			e.Reset ();			e.MoveNext ();			Assert.AreEqual (o[0], e.Current, "#GE03");		}		// Test GetEnumerator method again, this time using foreach		[Test]		public void Foreach ()		{			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) 			{				Assert.AreEqual (o[i], item, "#fe01." + i.ToString ());				i++;			}		}		#endregion		#region Count Tests		[Test]		public void Count_1()		{			Collection col = new Collection();			Assert.AreEqual(0,col.Count);			col.Add("a",null,null,null);			Assert.AreEqual(1,col.Count);			col.Add("b",null,null,null);			Assert.AreEqual(2,col.Count);			col.Add("c",null,null,null);			Assert.AreEqual(3,col.Count);			col.Add("d",null,null,null);			Assert.AreEqual(4,col.Count);			col.Remove(1);			col.Remove(1);			Assert.AreEqual(2,col.Count);			col.Remove(1);			col.Remove(1);			Assert.AreEqual(0,col.Count);		}		#endregion		#region IList Tests		[Test]		public void IList_1()		{			Collection col = new Collection();			string s = "abc";			col.Add(s,null,null,null);			Assert.AreEqual(false,((IList)col).IsFixedSize);			Assert.AreEqual(false,((IList)col).IsReadOnly);			Assert.AreEqual(false,((IList)col).IsSynchronized);		}		[Test]		public void IList_Add()		{			Collection col = new Collection();			string s = "abc";			((IList)col).Add(s);			((IList)col).Add(s);			Assert.AreEqual(s,col[1]);			Assert.AreEqual(s,col[2]);		}		[Test]		public void IList_Contains()		{			Collection col = new Collection();			string s = "abc";			((IList)col).Add(s);			((IList)col).Add(s);			Assert.IsTrue(((IList)col).Contains(s));		}		[Test]		public void IList_CopyTo()		{			Collection col = new Collection();			string s1 = "abc1";			string s2 = "abc2";			string s3 = "abc3";			((IList)col).Add(s1);			((IList)col).Add(s2);			((IList)col).Add(s3);			((IList)col).Add(s3);			((IList)col).Add(s2);			((IList)col).Add(s1);			object[] oarr = new object[6];			((IList)col).CopyTo(oarr,0);			Assert.AreEqual(s1,oarr[0]);			Assert.AreEqual(s2,oarr[1]);			Assert.AreEqual(s3,oarr[2]);			Assert.AreEqual(s3,oarr[3]);			Assert.AreEqual(s2,oarr[4]);			Assert.AreEqual(s1,oarr[5]);		}		[Test]		public void IList_Count()		{			Collection col = new Collection();			string s1 = "abc1";			string s2 = "abc2";			string s3 = "abc3";			((IList)col).Add(s1);			((IList)col).Add(s2);			((IList)col).Add(s3);			((IList)col).Add(s3);			((IList)col).Add(s2);			((IList)col).Add(s1);			Assert.AreEqual(6,((IList)col).Count);		}		[Test]		public void IList_IndexOf()		{			Collection col = new Collection();			string s1 = "abc1";			string s2 = "abc2";			string s3 = "abc3";			((IList)col).Add(s1);			((IList)col).Add(s2);			((IList)col).Add(s3);			Assert.AreEqual(0,((IList)col).IndexOf(s1));			Assert.AreEqual(1,((IList)col).IndexOf(s2));			Assert.AreEqual(2,((IList)col).IndexOf(s3));		}		[Test]#if NET_2_0		[ExpectedException(typeof(ArgumentOutOfRangeException))]#endif		public void IList_Insert_1()		{			Collection col = new Collection();			string s1 = "abc1";			string s2 = "abc2";			string s3 = "abc3";			((IList)col).Add(s1);			((IList)col).Add(s2);			((IList)col).Add(s3);			((IList)col).Add(s1);			((IList)col).Add(s2);			((IList)col).Add(s3);			((IList)col).Insert(-1,s1+s1);			((IList)col).Insert(2,s2+s2);			((IList)col).Insert(4,s3+s3);			Assert.AreEqual(9,col.Count);			Assert.AreEqual(s1+s1,col[1]);			Assert.AreEqual(s1,col[2]);			Assert.AreEqual(s2,col[3]);			Assert.AreEqual(s2+s2,col[4]);			Assert.AreEqual(s3,col[5]);			Assert.AreEqual(s3+s3,col[6]);			Assert.AreEqual(s1,col[7]);			Assert.AreEqual(s2,col[8]);			Assert.AreEqual(s3,col[9]);			((IList)col).Insert(8,s3 + s3 + s3);			Assert.AreEqual(10,col.Count);			Assert.AreEqual(s3 + s3 + s3,col[10]);		}		[Test]#if !NET_2_0		[ExpectedException(typeof(ArgumentOutOfRangeException))]#endif		public void IList_Insert_2()		{			Collection col = new Collection();			string s1 = "abc1";			string s2 = "abc2";			string s3 = "abc3";

⌨️ 快捷键说明

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