public static InArgument <T> GetInArgumentFromExpectedNode <T>(TestExpression te)
        {
            InArgument <T> retInArg = null;

            // leaf node:
            if (te.GetType() == typeof(TestExpression))
            {
                if (te.ExpectedNode is Activity <T> )
                {
                    retInArg = (Activity <T>)te.ExpectedNode;
                }
                else if (te.ExpectedNode is Variable <T> )
                {
                    retInArg = (Variable <T>)te.ExpectedNode;
                }
                else
                {
                    //Log.TraceInternal("Expect a generic type with type parameter: {0}", typeof(T).ToString());
                    //Log.TraceInternal("Expected node type is: {0}", te.ExpectedNode.GetType().ToString());
                    throw new NotSupportedException("Not supported expected node type");
                }
            }
            // non-leaf node:
            else if (te is TestBinaryExpression || te is TestUnaryExpression)
            {
                retInArg = (Activity <T>)te.CreateExpectedActivity();
            }

            return(retInArg);
        }
        static protected Activity <T> GetWorkflowElementFromExpectedNode <T>(TestExpression te)
        {
            Activity <T> we = null;

            if (te.ExpectedConversionException != null)
            {
                return(null);
            }

            // leaf node:
            if (te.GetType() == typeof(TestExpression))
            {
                if (te.ExpectedNode is Activity <T> )
                {
                    we = (Activity <T>)te.ExpectedNode;
                }
                else if (te.ExpectedNode is Variable <T> )
                {
                    we = new VariableValue <T>()
                    {
                        Variable = (Variable <T>)te.ExpectedNode
                    };
                }
                else
                {
                    throw new NotSupportedException("Not supported expected node type");
                }
            }
            // non-leaf node:
            else if (te is TestBinaryExpression || te is TestUnaryExpression)
            {
                we = (Activity <T>)te.CreateExpectedActivity();
            }

            return(we);
        }