예제 #1
0
		public void CopyToWithInsufficientSizeArray()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			ll.Add("item2");
			string[] strings = new string[2];
            Assert.Throws<ArgumentException>(() => ll.CopyTo(strings, 1));
		}
예제 #2
0
		public void CopyToWithNegativeIndex()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			string[] strings = new string[1];
            Assert.Throws<ArgumentOutOfRangeException>(() => ll.CopyTo(strings, -1));
		}
예제 #3
0
		public void CopyToWithIndexGreaterThanArrayLength()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			string[] strings = new string[1];
            Assert.Throws<ArgumentOutOfRangeException>(() => ll.CopyTo(strings, 2));
		}
예제 #4
0
		public void CopyToWithNonZeroIndex()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			ll.Add("item2");
			ll.Add("item3");
			string[] strings = new string[5];
			strings[0] = "string1";
			strings[1] = "string2";
			ll.CopyTo(strings, 2);
			Assert.IsTrue(strings[0].Equals("string1"), "Expected first element to be \"string1\" not " + strings[0]);
			Assert.IsTrue(strings[1].Equals("string2"), "Expected second element to be \"string2\" not " + strings[1]);
			Assert.IsTrue(strings[2].Equals("item1"), "Expected third element to be \"item1\" not " + strings[2]);
			Assert.IsTrue(strings[3].Equals("item2"), "Expected fourth element to be \"item2\" not " + strings[3]);
			Assert.IsTrue(strings[4].Equals("item3"), "Expected fifth element to be \"item3\" not " + strings[4]);
		}
예제 #5
0
		public void CopyToWithNullArray()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
            Assert.Throws<ArgumentNullException>(() => ll.CopyTo(null, 0));
		}
예제 #6
0
		public void CopyToWithZeroIndex()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			ll.Add("item2");
			ll.Add("item3");
			string[] strings = new string[3];
			ll.CopyTo(strings, 0);
			Assert.IsTrue(strings[0].Equals("item1"), "Expected first element to be \"item1\" not " + strings[0]);
			Assert.IsTrue(strings[1].Equals("item2"), "Expected second element to be \"item2\" not " + strings[1]);
			Assert.IsTrue(strings[2].Equals("item3"), "Expected third element to be \"item3\" not " + strings[2]);
		}
예제 #7
0
		public void CopyToWithInsufficientSizeArray()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			ll.Add("item2");
			string[] strings = new string[2];
			ll.CopyTo(strings, 1);
		}
예제 #8
0
		public void CopyToWithIndexGreaterThanArrayLength()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			string[] strings = new string[1];
			ll.CopyTo(strings, 2);
		}
예제 #9
0
		public void CopyToWithNegativeIndex()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			string[] strings = new string[1];
			ll.CopyTo(strings, -1);
		}
예제 #10
0
		public void CopyToWithNullArray()
		{
			LinkedList ll = new LinkedList();
			ll.Add("item1");
			ll.CopyTo(null, 0);
		}