Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ namespace Java.InteropTests
[TestFixture]
public class JavaBooleanArrayContractTests : JavaPrimitiveArrayContract<JavaBooleanArray, bool>
{
protected override ICollection<bool> CreateCollection (IEnumerable<bool> values)
{
return new JavaBooleanArray (values);
}

protected override ICollection<bool> CreateCollection (IList<bool> values)
{
return new JavaBooleanArray (values);
}

protected override ICollection<bool> CreateCollection (int length)
{
return new JavaBooleanArray (length);
}

protected override bool CreateValueA ()
{
return true;
Expand Down
14 changes: 14 additions & 0 deletions src/Java.Interop/Tests/Java.Interop/JavaCharArrayContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaCharArrayContractTests : JavaPrimitiveArrayContract<JavaCharArray, char>
{
protected override ICollection<char> CreateCollection (IEnumerable<char> values)
{
return new JavaCharArray (values);
}

protected override ICollection<char> CreateCollection (IList<char> values)
{
return new JavaCharArray (values);
}

protected override ICollection<char> CreateCollection (int length)
{
return new JavaCharArray (length);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaDoubleArrayContractTests : JavaPrimitiveArrayContract<JavaDoubleArray, double>
{
protected override ICollection<double> CreateCollection (IEnumerable<double> values)
{
return new JavaDoubleArray (values);
}

protected override ICollection<double> CreateCollection (IList<double> values)
{
return new JavaDoubleArray (values);
}

protected override ICollection<double> CreateCollection (int length)
{
return new JavaDoubleArray (length);
}
}
}

14 changes: 14 additions & 0 deletions src/Java.Interop/Tests/Java.Interop/JavaInt16ArrayContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaInt16ArrayContractTests : JavaPrimitiveArrayContract<JavaInt16Array, short>
{
protected override ICollection<short> CreateCollection (IEnumerable<short> values)
{
return new JavaInt16Array (values);
}

protected override ICollection<short> CreateCollection (IList<short> values)
{
return new JavaInt16Array (values);
}

protected override ICollection<short> CreateCollection (int length)
{
return new JavaInt16Array (length);
}
}
}

14 changes: 14 additions & 0 deletions src/Java.Interop/Tests/Java.Interop/JavaInt32ArrayContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaInt32ArrayContractTests : JavaPrimitiveArrayContract<JavaInt32Array, int>
{
protected override ICollection<int> CreateCollection (IEnumerable<int> values)
{
return new JavaInt32Array (values);
}

protected override ICollection<int> CreateCollection (IList<int> values)
{
return new JavaInt32Array (values);
}

protected override ICollection<int> CreateCollection (int length)
{
return new JavaInt32Array (length);
}
}
}

14 changes: 14 additions & 0 deletions src/Java.Interop/Tests/Java.Interop/JavaInt64ArrayContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaInt64ArrayContractTests : JavaPrimitiveArrayContract<JavaInt64Array, long>
{
protected override ICollection<long> CreateCollection (IEnumerable<long> values)
{
return new JavaInt64Array (values);
}

protected override ICollection<long> CreateCollection (IList<long> values)
{
return new JavaInt64Array (values);
}

protected override ICollection<long> CreateCollection (int length)
{
return new JavaInt64Array (length);
}
}
}

23 changes: 6 additions & 17 deletions src/Java.Interop/Tests/Java.Interop/JavaPrimitiveArrayContract.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using Java.Interop;

Expand All @@ -22,11 +21,9 @@ protected override TElement CreateValueB ()
return FromInt32 ((int) 'B');
}

protected override ICollection<TElement> CreateCollection (IEnumerable<TElement> values)
{
var array = (JavaPrimitiveArray<TElement>) Activator.CreateInstance (typeof (TArray), values);
return array;
}
protected abstract ICollection<TElement> CreateCollection (IList<TElement> values);

protected abstract ICollection<TElement> CreateCollection (int length);

protected TElement FromInt32 (int value)
{
Expand All @@ -36,17 +33,9 @@ protected TElement FromInt32 (int value)
[Test]
public void Constructor_Exceptions ()
{
var ctor = typeof (TArray).GetConstructor (new[]{ typeof (IList<TElement>) });
var ex = Assert.Throws<TargetInvocationException> (() => ctor.Invoke (new object[]{ null }));
Assert.IsTrue (ex.InnerException is ArgumentNullException);

ctor = typeof (TArray).GetConstructor (new[]{ typeof (IEnumerable<TElement>) });
ex = Assert.Throws<TargetInvocationException> (() => ctor.Invoke (new object[]{ null }));
Assert.IsTrue (ex.InnerException is ArgumentNullException);

ctor = typeof (TArray).GetConstructor (new[]{ typeof (int) });
ex = Assert.Throws<TargetInvocationException> (() => ctor.Invoke (new object[]{ -1 }));
Assert.IsTrue (ex.InnerException is ArgumentException);
Assert.Throws<ArgumentNullException>(() => CreateCollection ((IEnumerable<TElement>) null));
Assert.Throws<ArgumentNullException>(() => CreateCollection ((IList<TElement>) null));
Assert.Throws<ArgumentException>(() => CreateCollection (-1));
}

[Test]
Expand Down
14 changes: 14 additions & 0 deletions src/Java.Interop/Tests/Java.Interop/JavaSByteArrayContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaSByteArrayContractTests : JavaPrimitiveArrayContract<JavaSByteArray, sbyte>
{
protected override ICollection<sbyte> CreateCollection (IEnumerable<sbyte> values)
{
return new JavaSByteArray (values);
}

protected override ICollection<sbyte> CreateCollection (IList<sbyte> values)
{
return new JavaSByteArray (values);
}

protected override ICollection<sbyte> CreateCollection (int length)
{
return new JavaSByteArray (length);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Java.InteropTests
[TestFixture]
public class JavaSingleArrayContractTests : JavaPrimitiveArrayContract<JavaSingleArray, float>
{
protected override ICollection<float> CreateCollection (IEnumerable<float> values)
{
return new JavaSingleArray (values);
}

protected override ICollection<float> CreateCollection (IList<float> values)
{
return new JavaSingleArray (values);
}

protected override ICollection<float> CreateCollection (int length)
{
return new JavaSingleArray (length);
}
}
}

1 change: 0 additions & 1 deletion src/Java.Interop/Tests/Java.Interop/JniEnvironmentTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;

using Java.Interop;
Expand Down
1 change: 0 additions & 1 deletion src/Java.Interop/Tests/Java.Interop/JniTransitionTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Reflection;

using Java.Interop;

Expand Down