public void ConstructorTest()
        {
            try {
                IavaJointCollection jointCollection = new IavaJointCollection();

                // Make sure there is an element for every joint type
                Assert.AreEqual((int)IavaJointType.Count, jointCollection.Count);
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }
        /// <summary>
        /// Default Constructor
        /// </summary>
        public IavaSkeleton()
        {
            Joints = new IavaJointCollection();

            IavaJoint iavaJoint = new IavaJoint();

            // Initialize the Joint Collection
            for (IavaJointType type = 0; type < IavaJointType.Count; type++) {
                iavaJoint.JointType = type;
                Joints[type] = iavaJoint;
            }
        }
        /// <summary>
        /// Draws a line between the specified joints of a skeleton
        /// </summary>
        /// <param name="joints">Joints in a skeleton</param>
        /// <param name="brush">Color of the lines to draw</param>
        /// <param name="jointIDs">Joints to be connected by the poly line</param>
        /// <returns></returns>
        private Polyline GetBodySegment(IavaJointCollection joints, Brush brush, params IavaJointType[] jointIDs)
        {
            PointCollection points = new PointCollection(jointIDs.Length);
            for (int i = 0; i < jointIDs.Length; ++i) {
                points.Add(ScalePoint(joints[jointIDs[i]].Position.X, joints[jointIDs[i]].Position.Y, ActualWidth, ActualHeight));
            }

            Polyline polyline = new Polyline();
            polyline.Points = points;
            polyline.Stroke = brush;
            polyline.StrokeThickness = 5;
            return polyline;
        }
        public void EqualityTest()
        {
            try {
                IavaJointCollection collection1 = new IavaJointCollection();
                collection1[IavaJointType.AnkleLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };
                collection1[IavaJointType.AnkleRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                collection1[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                collection1[IavaJointType.ElbowRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };

                IavaJointCollection collection2 = new IavaJointCollection();
                collection2[IavaJointType.AnkleLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };
                collection2[IavaJointType.AnkleRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                collection2[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                collection2[IavaJointType.ElbowRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };

                IavaJointCollection collection3 = new IavaJointCollection();
                collection3[IavaJointType.HipCenter] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };
                collection3[IavaJointType.AnkleRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                collection3[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                collection3[IavaJointType.Spine] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };

                // Make sure collection1 does not equal null
                Assert.IsFalse(collection1 == null);

                // Make sure null does not equal collection1
                Assert.IsFalse(null == collection1);

                // Make sure collection1 and collection3 are not equal
                Assert.IsFalse(collection1 == collection3);

                // Make sure collection1 and collection2 are equal
                Assert.IsTrue(collection1 == collection2);

                // Make sure collection1 equals itself
                Assert.IsTrue(collection1 == collection1);
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }
        public void ItemTest()
        {
            try {
                IavaJointCollection jointCollection = new IavaJointCollection();

                IavaJoint joint = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };

                jointCollection[IavaJointType.AnkleLeft] = joint;

                Assert.AreEqual(joint, jointCollection[IavaJointType.AnkleLeft]);
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }
        public void GetEnumeratorTest()
        {
            try {
                IavaJointCollection collection = new IavaJointCollection();

                // Make sure we are getting an Enumerator
                Assert.IsNotNull(collection.GetEnumerator());
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }
        public void ExplicitCastTest()
        {
            try {
                // Create the Kinect Object
                JointCollection kinectCollection = (JointCollection)FormatterServices.GetSafeUninitializedObject(typeof(JointCollection));
                PrivateObject po = new PrivateObject(kinectCollection);
                po.SetFieldOrProperty("_skeletonData", new Joint[20]);

                // Set some Joints
                // JointType is readonly hence the FUBAR way of doing this...
                po = new PrivateObject(new Joint());
                po.SetFieldOrProperty("JointType", JointType.AnkleLeft);
                po.SetFieldOrProperty("TrackingState", JointTrackingState.Inferred);
                kinectCollection[JointType.AnkleLeft] = (Joint)po.Target;
                po = new PrivateObject(new Joint());
                po.SetFieldOrProperty("JointType", JointType.AnkleRight);
                po.SetFieldOrProperty("TrackingState", JointTrackingState.NotTracked);
                kinectCollection[JointType.AnkleRight] = (Joint)po.Target;
                po = new PrivateObject(new Joint());
                po.SetFieldOrProperty("JointType", JointType.ElbowLeft);
                po.SetFieldOrProperty("TrackingState", JointTrackingState.Tracked);
                kinectCollection[JointType.ElbowLeft] = (Joint)po.Target;
                po = new PrivateObject(new Joint());
                po.SetFieldOrProperty("JointType", JointType.ElbowRight);
                po.SetFieldOrProperty("TrackingState", JointTrackingState.NotTracked);
                kinectCollection[JointType.ElbowRight] = (Joint)po.Target;

                // Create the Iava equivalent
                IavaJointCollection iavaCollection = new IavaJointCollection();
                iavaCollection[IavaJointType.AnkleLeft] = new IavaJoint() { JointType = IavaJointType.AnkleLeft, TrackingState = IavaJointTrackingState.Inferred };
                iavaCollection[IavaJointType.AnkleRight] = new IavaJoint() { JointType = IavaJointType.AnkleRight, TrackingState = IavaJointTrackingState.NotTracked };
                iavaCollection[IavaJointType.ElbowLeft] = new IavaJoint() { JointType = IavaJointType.ElbowLeft, TrackingState = IavaJointTrackingState.Tracked };
                iavaCollection[IavaJointType.ElbowRight] = new IavaJoint() { JointType = IavaJointType.ElbowRight, TrackingState = IavaJointTrackingState.NotTracked };

                // Test object as a whole
                Assert.AreEqual(iavaCollection, (IavaJointCollection)kinectCollection);

                // Set the Kinect Object to null
                kinectCollection = null;

                // Make sure we don't attempt to cast nulls
                Assert.IsNull((IavaJointCollection)kinectCollection);
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }
        public void EqualsTest()
        {
            try {
                IavaJointCollection collection1 = new IavaJointCollection();
                collection1[IavaJointType.AnkleLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };
                collection1[IavaJointType.AnkleRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                collection1[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                collection1[IavaJointType.ElbowRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };

                IavaJointCollection collection2 = new IavaJointCollection();
                collection2[IavaJointType.AnkleLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };
                collection2[IavaJointType.AnkleRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                collection2[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                collection2[IavaJointType.ElbowRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };

                IavaJointCollection collection3 = new IavaJointCollection();
                collection3[IavaJointType.HipCenter] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };
                collection3[IavaJointType.AnkleRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                collection3[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                collection3[IavaJointType.Spine] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };

                // Make sure collection1 does not equal null
                Assert.IsFalse(collection1.Equals(null));

                // Make sure eventArgs1 does not equal a completly different object
                Assert.IsFalse(collection1.Equals("Not a collection."));

                // Make sure collection1 and collection3 are not equal
                Assert.IsFalse(collection1.Equals(collection3));

                // Make sure collection1 and collection2 are equal
                Assert.IsTrue(collection1.Equals(collection2));

                // Make sure collection1 equals itself
                Assert.IsTrue(collection1.Equals(collection1));
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }
        public void JointsTest()
        {
            try {
                IavaSkeleton skeleton = new IavaSkeleton();

                IavaJointCollection jointCollection = new IavaJointCollection();
                jointCollection[IavaJointType.ElbowLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                jointCollection[IavaJointType.FootRight] = new IavaJoint() { TrackingState = IavaJointTrackingState.Tracked };
                jointCollection[IavaJointType.Head] = new IavaJoint() { TrackingState = IavaJointTrackingState.NotTracked };
                jointCollection[IavaJointType.KneeLeft] = new IavaJoint() { TrackingState = IavaJointTrackingState.Inferred };

                // Set the Joints
                skeleton.Joints = jointCollection;

                // Make sure the property set correctly
                Assert.AreEqual(jointCollection, skeleton.Joints);
            }
            catch (Exception ex) {
                Assert.Fail(ex.Message);
            }
        }