diff --git a/src/Java.Interop/Tests/Java.Interop/JavaBooleanArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaBooleanArrayContractTests.cs index 73241f76e..3f13eaa42 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaBooleanArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaBooleanArrayContractTests.cs @@ -11,6 +11,21 @@ namespace Java.InteropTests [TestFixture] public class JavaBooleanArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaBooleanArray (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaBooleanArray (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaBooleanArray (length); + } + protected override bool CreateValueA () { return true; diff --git a/src/Java.Interop/Tests/Java.Interop/JavaCharArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaCharArrayContractTests.cs index 343d93288..350df67fa 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaCharArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaCharArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaCharArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaCharArray (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaCharArray (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaCharArray (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JavaDoubleArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaDoubleArrayContractTests.cs index ef263b525..6f00e3ccc 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaDoubleArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaDoubleArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaDoubleArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaDoubleArray (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaDoubleArray (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaDoubleArray (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JavaInt16ArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaInt16ArrayContractTests.cs index 1462c449f..1705edd84 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaInt16ArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaInt16ArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaInt16ArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaInt16Array (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaInt16Array (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaInt16Array (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JavaInt32ArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaInt32ArrayContractTests.cs index 1dd9f8e6a..ddc2bc911 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaInt32ArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaInt32ArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaInt32ArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaInt32Array (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaInt32Array (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaInt32Array (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JavaInt64ArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaInt64ArrayContractTests.cs index 32c8586bf..f384760e8 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaInt64ArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaInt64ArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaInt64ArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaInt64Array (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaInt64Array (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaInt64Array (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JavaPrimitiveArrayContract.cs b/src/Java.Interop/Tests/Java.Interop/JavaPrimitiveArrayContract.cs index 59b9d4334..d20c52a86 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaPrimitiveArrayContract.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaPrimitiveArrayContract.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Java.Interop; @@ -22,11 +21,9 @@ protected override TElement CreateValueB () return FromInt32 ((int) 'B'); } - protected override ICollection CreateCollection (IEnumerable values) - { - var array = (JavaPrimitiveArray) Activator.CreateInstance (typeof (TArray), values); - return array; - } + protected abstract ICollection CreateCollection (IList values); + + protected abstract ICollection CreateCollection (int length); protected TElement FromInt32 (int value) { @@ -36,17 +33,9 @@ protected TElement FromInt32 (int value) [Test] public void Constructor_Exceptions () { - var ctor = typeof (TArray).GetConstructor (new[]{ typeof (IList) }); - var ex = Assert.Throws (() => ctor.Invoke (new object[]{ null })); - Assert.IsTrue (ex.InnerException is ArgumentNullException); - - ctor = typeof (TArray).GetConstructor (new[]{ typeof (IEnumerable) }); - ex = Assert.Throws (() => ctor.Invoke (new object[]{ null })); - Assert.IsTrue (ex.InnerException is ArgumentNullException); - - ctor = typeof (TArray).GetConstructor (new[]{ typeof (int) }); - ex = Assert.Throws (() => ctor.Invoke (new object[]{ -1 })); - Assert.IsTrue (ex.InnerException is ArgumentException); + Assert.Throws(() => CreateCollection ((IEnumerable) null)); + Assert.Throws(() => CreateCollection ((IList) null)); + Assert.Throws(() => CreateCollection (-1)); } [Test] diff --git a/src/Java.Interop/Tests/Java.Interop/JavaSByteArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaSByteArrayContractTests.cs index 4f897fe15..64228bd27 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaSByteArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaSByteArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaSByteArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaSByteArray (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaSByteArray (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaSByteArray (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JavaSingleArrayContractTests.cs b/src/Java.Interop/Tests/Java.Interop/JavaSingleArrayContractTests.cs index 66c510a0c..7d3d3c303 100644 --- a/src/Java.Interop/Tests/Java.Interop/JavaSingleArrayContractTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JavaSingleArrayContractTests.cs @@ -11,6 +11,20 @@ namespace Java.InteropTests [TestFixture] public class JavaSingleArrayContractTests : JavaPrimitiveArrayContract { + protected override ICollection CreateCollection (IEnumerable values) + { + return new JavaSingleArray (values); + } + + protected override ICollection CreateCollection (IList values) + { + return new JavaSingleArray (values); + } + + protected override ICollection CreateCollection (int length) + { + return new JavaSingleArray (length); + } } } diff --git a/src/Java.Interop/Tests/Java.Interop/JniEnvironmentTests.cs b/src/Java.Interop/Tests/Java.Interop/JniEnvironmentTests.cs index 3164c216b..b24626161 100644 --- a/src/Java.Interop/Tests/Java.Interop/JniEnvironmentTests.cs +++ b/src/Java.Interop/Tests/Java.Interop/JniEnvironmentTests.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using System.Runtime.InteropServices; using Java.Interop; diff --git a/src/Java.Interop/Tests/Java.Interop/JniTransitionTest.cs b/src/Java.Interop/Tests/Java.Interop/JniTransitionTest.cs index 7fedd4158..565d100a8 100644 --- a/src/Java.Interop/Tests/Java.Interop/JniTransitionTest.cs +++ b/src/Java.Interop/Tests/Java.Interop/JniTransitionTest.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using Java.Interop;