newRange.InsertRange (newRange.Count, li);
Assert.AreEqual (2, newRange.Count);
}
+
+ [Test]
+ public void InsertSelfTest()
+ {
+ List <int> range = new List <int> (5);
+ for (int i = 0; i < 5; ++ i)
+ range.Add (i);
+
+ range.InsertRange(2, range);
+ Assert.AreEqual (10, range.Count);
+ Assert.AreEqual (0, range [0]);
+ Assert.AreEqual (1, range [1]);
+ Assert.AreEqual (0, range [2]);
+ Assert.AreEqual (1, range [3]);
+ Assert.AreEqual (2, range [4]);
+ Assert.AreEqual (3, range [5]);
+ Assert.AreEqual (4, range [6]);
+ Assert.AreEqual (2, range [7]);
+ Assert.AreEqual (3, range [8]);
+ Assert.AreEqual (4, range [9]);
+ }
[Test, ExpectedException (typeof (ArgumentNullException))]
public void InsertRangeNullTest ()
Assert.AreEqual (1, l.IndexOf (200), "Could not find value");
}
+
+ [Test, ExpectedException(typeof (ArgumentException))]
+ public void IList_InsertInvalidType ()
+ {
+ IList list = _list1 as IList;
+ list.Insert(0, new object());
+ }
+
+ [Test, ExpectedException(typeof (ArgumentException))]
+ public void IList_AddInvalidType()
+ {
+ IList list = _list1 as IList;
+ list.Add(new object());
+ }
+
+ [Test]
+ public void IList_RemoveInvalidType()
+ {
+ IList list = _list1 as IList;
+ int nCount = list.Count;
+ list.Remove(new object());
+ Assert.AreEqual(nCount, list.Count);
+ }
[Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
public void IndexOfOutOfRangeTest ()
}
[Test]
+ [Category ("TargetJvmNotWorking")]
public void SerializeTest ()
{
List <int> list = new List <int> ();
list.Add (0);
list.Add (7);
+#if TARGET_JVM
+ BinaryFormatter bf = (BinaryFormatter)vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (false);
+#else
BinaryFormatter bf = new BinaryFormatter ();
+#endif // TARGET_JVM
MemoryStream ms = new MemoryStream ();
bf.Serialize (ms, list);
}
[Test]
+ [Category ("TargetJvmNotWorking")]
public void DeserializeTest ()
{
MemoryStream ms = new MemoryStream ();
ms.Write (_serializedList, 0, _serializedList.Length);
ms.Position = 0;
+#if TARGET_JVM
+ BinaryFormatter bf = (BinaryFormatter)vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (false);
+#else
BinaryFormatter bf = new BinaryFormatter ();
+#endif // TARGET_JVM
List<int> list = (List<int>) bf.Deserialize (ms);
Assert.AreEqual (3, list.Count, "#1");
Assert.AreEqual (5, list [0], "#2");
l.Sort ();
// two element -> sort -> exception!
}
+
+ [Test]
+ void IList_Contains_InvalidType()
+ {
+ List<string> list = new List<string>();
+ list.Add("foo");
+ Assert.IsFalse (((IList)list).Contains(new object()));
+ }
+
+ [Test]
+ void IList_IndexOf_InvalidType()
+ {
+ List<string> list = new List<string>();
+ list.Add("foo");
+ Assert.AreEqual (-1, ((IList)list).IndexOf(new object()));
+ }
// for bug #77277 test case
[Test]
Assert.AreEqual (2, list.LastIndexOf (item0), "#4");
Assert.AreEqual (2, list.LastIndexOf (new EquatableClass (0)), "#5");
}
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SetItem_OutOfRange()
+ {
+ List<string> list = new List<string>();
+ list[0] = "foo";
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SetItem_IList_OutOfRange()
+ {
+ IList<string> list = new List<string>();
+ list[0] = "foo";
+ }
public class EquatableClass : IEquatable<EquatableClass>
{