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);
        }
Exemplo n.º 2
0
        public static void ValidateReferenceExpressionXaml <T>(TestExpression te)
        {
            Expression <Func <ActivityContext, T> > lambdaExpression = (Expression <Func <ActivityContext, T> >)te.CreateLambdaExpresson <T>();
            //Log.TraceInternal("Expression: {0}", lambdaExpression.ToString());

            Activity expectedActivity = te.CreateExpectedActivity() as Activity;
            Activity actualActivity   = ExpressionServices.ConvertReference(lambdaExpression);

            ValidateActivity(expectedActivity, actualActivity);
        }
Exemplo n.º 3
0
        private static readonly string s_path = string.Empty; //DirectoryAssistance.GetTestBinsDirectory("TempFile.txt");

        public static void ValidateExpressionXaml <T>(TestExpression te)
        {
            Activity expectedActivity = null, actualActivity = null;

            Expression <Func <ActivityContext, T> > lambdaExpression = null;

            lambdaExpression = (Expression <Func <ActivityContext, T> >)te.CreateLambdaExpresson <T>();
            //Log.TraceInternal("Expression: {0}", lambdaExpression.ToString());

            expectedActivity = te.CreateExpectedActivity() as Activity;

            if (te.ExpectedConversionException != null)
            {
                ExceptionHelpers.CheckForException(
                    te.ExpectedConversionException.GetType(), te.ExpectedConversionException.Message,
                    () => { actualActivity = ExpressionServices.Convert(lambdaExpression); }, true);
            }
            else
            {
                actualActivity = ExpressionServices.Convert(lambdaExpression);
                ValidateActivity(expectedActivity, actualActivity);
            }
        }
        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);
        }