+ #region Bug 80299
+
+ enum ByteEnum : byte {}
+ enum IntEnum : int {}
+
+ [Test]
+ public void TestByteEnumArrayToByteArray ()
+ {
+ ByteEnum[] a = new ByteEnum[] {(ByteEnum) 1, (ByteEnum) 2};
+ byte[] b = new byte[a.Length];
+ a.CopyTo (b, 0);
+ }
+
+ [Test]
+ public void TestByteEnumArrayToIntArray ()
+ {
+ ByteEnum[] a = new ByteEnum[] {(ByteEnum) 1, (ByteEnum) 2};
+ int[] b = new int[a.Length];
+ a.CopyTo (b, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArrayTypeMismatchException))]
+ public void TestIntEnumArrayToByteArray ()
+ {
+ IntEnum[] a = new IntEnum[] {(IntEnum) 1, (IntEnum) 2};
+ byte[] b = new byte[a.Length];
+ a.CopyTo (b, 0);
+ }
+
+ [Test]
+ public void TestIntEnumArrayToIntArray ()
+ {
+ IntEnum[] a = new IntEnum[] {(IntEnum) 1, (IntEnum) 2};
+ int[] b = new int[a.Length];
+ a.CopyTo (b, 0);
+ }
+
+ #endregion
+
+#if NET_2_0
+ [Test] // bug #322248
+ public void IEnumerator_Reset ()
+ {
+ int[] array = new int[] { 1, 2, 3};
+ IEnumerator<int> e = ((IEnumerable<int>)array).GetEnumerator ();
+ Assert ("#A1", e.MoveNext ());
+ AssertEquals ("#A2", 1, e.Current);
+ Assert ("#A3", e.MoveNext ());
+ AssertEquals ("#A4", 2, e.Current);
+
+ e.Reset ();
+
+ Assert ("#C1", e.MoveNext ());
+ AssertEquals ("#C2", 1, e.Current);
+ }
+
+ [Test]
+ public void IEnumerator_Current_Finished ()
+ {
+ int[] array = new int[] { 1, 2, 3 };
+ IEnumerator<int> e = ((IEnumerable<int>)array).GetEnumerator ();
+ Assert ("#A1", e.MoveNext ());
+ AssertEquals ("#A2", 1, e.Current);
+ Assert ("#A3", e.MoveNext ());
+ AssertEquals ("#A4", 2, e.Current);
+ Assert ("#A5", e.MoveNext ());
+ AssertEquals ("#A6", 3, e.Current);
+ Assert ("#A6", !e.MoveNext ());
+
+ try {
+ Fail ("#B1:" + e.Current);
+ } catch (InvalidOperationException ex) {
+ // Enumeration already finished
+ AssertEquals ("#B2", typeof (InvalidOperationException), ex.GetType ());
+ AssertNull ("#B3", ex.InnerException);
+ AssertNotNull ("#B4", ex.Message);
+ }
+ }
+
+ [Test]
+ public void IEnumerator_Current_NotStarted ()
+ {
+ int[] array = new int[] { 1, 2, 3 };
+ IEnumerator<int> e = ((IEnumerable<int>)array).GetEnumerator ();
+
+ try {
+ Fail ("#A1:" + e.Current);
+ } catch (InvalidOperationException ex) {
+ // Enumeration has not started. Call MoveNext
+ AssertEquals ("#A2", typeof (InvalidOperationException), ex.GetType ());
+ AssertNull ("#A3", ex.InnerException);
+ AssertNotNull ("#A4", ex.Message);
+ }
+ }
+
+ [Test]
+ public void IEnumerator_Current_Reset ()
+ {
+ int[] array = new int[] { 1, 2, 3 };
+ IEnumerator<int> e = ((IEnumerable<int>)array).GetEnumerator ();
+ e.MoveNext ();
+ e.Reset ();
+
+ try {
+ Fail ("#B1:" + e.Current);
+ } catch (InvalidOperationException ex) {
+ // Enumeration has not started. Call MoveNext
+ AssertEquals ("#B2", typeof (InvalidOperationException), ex.GetType ());
+ AssertNull ("#B3", ex.InnerException);
+ AssertNotNull ("#B4", ex.Message);
+ }
+ }
+#endif
+}