public void TestStates()
        {
            string stringToParse = "ExpressionParserTestEntity";
            object result        =
                mExpressionParser.EvaluateExpression(stringToParse, new CodeContext(mParentElementRuntime));

            if (result != ObjectFinder.Self.GetIElement("ExpressionParserTestEntity"))
            {
                throw new Exception("The returned value for ExpressionParserTestEntity.VariableState.Left does not match the Left state.  Result:\n" +
                                    result);
            }



            // First we'll do the simple tests of seeing if we can find the states
            string leftVariableStateString = "ExpressionParserTestEntity.VariableState.Left";

            result =
                mExpressionParser.EvaluateExpression(leftVariableStateString, new CodeContext(mParentElementRuntime));
            if (result != mElementRuntime.AssociatedIElement.GetState("Left"))
            {
                throw new Exception("The returned value for ExpressionParserTestEntity.VariableState.Left does not match the Left state.  Result:\n" +
                                    result);
            }

            string stateCategory = "ExpressionParserTestEntity.StateCategory";

            result =
                mExpressionParser.EvaluateExpression(stateCategory, new CodeContext(mParentElementRuntime));
            if (result == null || result is StateSaveCategory == false)
            {
                throw new Exception("State Category isn't returning properly");
            }


            string topVariableStateList = "ExpressionParserTestEntity.StateCategory.Top";

            result =
                mExpressionParser.EvaluateExpression(topVariableStateList, new CodeContext(mParentElementRuntime));

            if (result != mElementRuntime.AssociatedIElement.GetState("Top"))
            {
                throw new Exception("The returned variable for " + topVariableStateList + " does not match the Top state");
            }

            topVariableStateList = "StateCategory.Top";
            result =
                mExpressionParser.EvaluateExpression(topVariableStateList, new CodeContext(mElementRuntime));

            if (result != mElementRuntime.AssociatedIElement.GetState("Top"))
            {
                throw new Exception("The returned variable for " + topVariableStateList + " does not match the Top state");
            }
            // Now what happens when we actually set them?



            string line = "this.FirstObject.CurrentState = ExpressionParserTestEntity.VariableState.Left;";

            string[] lines = new string[] { line };
            // prepare the variable so we know it changes
            mParentElementRuntime.ContainedElements[0].RelativeX = 0;
            mPlugin.ApplyLinesInternal(lines, 0, 1, mParentElementRuntime.AssociatedIElement, new CodeContext(mParentElementRuntime));
            mParentElementRuntime.ContainedElements[0].ForceUpdateDependencies();
            if (mParentElementRuntime.ContainedElements[0].X != -10)
            {
                throw new Exception("Assignment of states on contained Entities isn't working");
            }

            line  = "this.FirstObject.SomeNewVar;";
            lines = new string[] { line };
            // prepare the variable so we know it changes
            var evaluated = mExpressionParser.EvaluateExpression(line, new CodeContext(mParentElementRuntime), ExpressionParseType.Evaluate);

            if ((double)evaluated != -10.0)
            {
                throw new Exception("Getting the value of custom variables set by states isn't working!");
            }



            line  = "this.FirstObject.CurrentState = ExpressionParserTestEntity.StateCategory.Top;";
            lines = new string[] { line };
            // prepare the variable so we know it changes
            mParentElementRuntime.ContainedElements[0].RelativeY = 0;
            mPlugin.ApplyLinesInternal(lines, 0, 1, mParentElementRuntime.AssociatedIElement, new CodeContext(mParentElementRuntime));
            mParentElementRuntime.ContainedElements[0].ForceUpdateDependencies();
            if (mParentElementRuntime.ContainedElements[0].Y != 10)
            {
                throw new Exception("Assignment of states in categories on contained Entities isn't working");
            }


            Type type;

            mPlugin.GetTypeStringForValue("CurrentStateCategoryState", mElementRuntime, new CodeContext(mElementRuntime), out type);
            if (type != typeof(string))
            {
                throw new Exception("States need to come back as strings, but they're not!");
            }

            line              = "this.CurrentStateCategoryState = StateCategory.Top";
            lines             = new string[] { line };
            mElementRuntime.Y = 0;
            mPlugin.ApplyLinesInternal(lines, 0, 1, mElementRuntime.AssociatedIElement, new CodeContext(mElementRuntime));
            mElementRuntime.ForceUpdateDependencies();
            if (mElementRuntime.Y != 10)
            {
                throw new Exception("Assignment of categorized states on Entities isn't working");
            }
        }