forked from dotnet/java-interop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaArrayContract.cs
More file actions
52 lines (45 loc) · 1 KB
/
JavaArrayContract.cs
File metadata and controls
52 lines (45 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Linq;
using Java.Interop;
using Cadenza.Collections.Tests;
using NUnit.Framework;
namespace Java.InteropTests
{
public abstract class JavaArrayContract<T> : ListContract<T>
{
int lrefStartCount;
#if __ANDROID__
[TestFixtureSetUp]
#else // __ANDROID__
[OneTimeSetUp]
#endif // __ANDROID__
public void StartArrayTests ()
{
lrefStartCount = JniEnvironment.LocalReferenceCount;
}
#if __ANDROID__
[TestFixtureTearDown]
#else // __ANDROID__
[OneTimeTearDown]
#endif // __ANDROID__
public void EndArrayTests ()
{
int lref = JniEnvironment.LocalReferenceCount;
Assert.AreEqual (lrefStartCount, lref, "JNI local references");
}
[Test]
public void ToArray ()
{
var expected = new[] {
CreateValueA (),
CreateValueB (),
};
var ja = (JavaArray<T>) CreateCollection (expected);
var a = ja.ToArray ();
Assert.IsTrue (SequenceEqual (expected, a));
ja.Dispose ();
DisposeCollection (a);
DisposeCollection (expected);
}
}
}