11using System.Reflection;
12using System.Collections;
32 Assert.That(oldHand.
Id, Is.EqualTo(newHand.
Id));
34 for (
int j = 0; j < 5; j++) {
37 Assert.That(oldFinger.
Id, Is.EqualTo(newFinger.
Id));
47 private void assertObjectsEqual(
string objectName,
object a,
object b) {
48 if ((a ==
null) != (b ==
null)) {
49 Assert.Fail(
"For " + objectName +
", one object was null an the other was not.");
53 Type typeA = a.GetType();
54 Type typeB = b.GetType();
57 Assert.Fail(
"For " + objectName +
", object Type " + typeA +
" is not equal to type " + typeB +
".");
60 if (typeA.IsValueType) {
61 Assert.That(a, Is.EqualTo(b), objectName);
66 IList aList = a as IList;
67 IList bList = b as IList;
69 Assert.That(aList.Count, Is.EqualTo(bList.Count), objectName +
".Count");
71 for (
int i = 0; i < aList.Count; i++) {
72 assertObjectsEqual(objectName +
"[" + i +
"]", aList[i], bList[i]);
75 FieldInfo[] fields = typeA.GetFields(BindingFlags.Public | BindingFlags.Instance);
76 foreach (FieldInfo field
in fields) {
77 assertObjectsEqual(objectName +
"." + field.Name, field.GetValue(a), field.GetValue(b));
80 PropertyInfo[] properties = typeA.GetProperties(BindingFlags.Public | BindingFlags.Instance);
81 foreach (PropertyInfo property
in properties) {
82 if (property.GetIndexParameters().Length == 0) {
85 propA =
property.GetValue(a,
null);
86 }
catch (Exception exceptionA) {
88 property.GetValue(b,
null);
89 Assert.Fail(
"For " + objectName +
", one property threw an exception where the other did not.");
91 }
catch (Exception exceptionB) {
92 Assert.That(exceptionA.GetType(), Is.EqualTo(exceptionB.GetType()),
"For " + objectName +
", both properties threw exceptions but their types were different.");
97 object propB =
property.GetValue(b,
null);
99 assertObjectsEqual(objectName +
"." + property.Name, propA, propB);
124 for (
int j = 0; j < 5; j++) {
The Finger class represents a tracked finger.
override string ToString()
A string containing a brief, human readable description of the Finger object.
int Id
A unique ID assigned to this Finger object, whose value remains the same across consecutive frames wh...
Finger.FingerType Type
The type of this finger.
Vector TipPosition
The tip position of this Finger.
The Frame class represents a set of hand and finger tracking data detected in a single frame.
List< Hand > Hands
The list of Hand objects detected in this frame, given in arbitrary order. The list can be empty if n...
The Hand class reports the physical characteristics of a detected hand.
Vector PalmPosition
The center position of the palm.
int Id
A unique ID assigned to this Hand object, whose value remains the same across consecutive frames whil...
List< Finger > Fingers
The list of Finger objects detected in this frame that are attached to this hand, given in order from...
void assertVectorsEqual(Vector a, Vector b, string vectorName="Vector")
The LeapQuaternion struct represents a rotation in three-dimensional space.
static readonly LeapQuaternion Identity
The identity quaternion.
The Vector struct represents a three-component mathematical vector or point such as a direction or po...
static readonly Vector Forward
The unit vector pointing forward along the negative z-axis: (0, 0, -1)