コード例 #1
0
        public void NewAnArrayOfValueType()
        {
            TestNewArray <int[]> testNewArray = new TestNewArray <int[]>();

            testNewArray.Bounds.Add(new InArgument <int>(3));

            Variable <int[]> result = new Variable <int[]>()
            {
                Name = "Result"
            };

            testNewArray.Result = result;

            TestSequence seq = new TestSequence
            {
                Variables  = { result },
                Activities =
                {
                    testNewArray,
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).ToString(),HintMessage                                           = new int[3].ToString()
                    },
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).Length.ToString(),HintMessage                                           = "3"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #2
0
        public void NewJaggedArray()
        {
            //TestParameters.DisableXamlRoundTrip = true;
            TestNewArray <int[][]> jaggedArray = new TestNewArray <int[][]>
            {
                Bounds =
                {
                    new InArgument <int>(2),
                    new InArgument <int>(5)
                }
            };

            Variable <int[][]> result = new Variable <int[][]>();

            jaggedArray.Result = result;

            TestSequence seq = new TestSequence
            {
                Variables  = { result },
                Activities =
                {
                    jaggedArray,
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).ToString(),HintMessage                                            = new int[2][].ToString()
                    },
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).Length.ToString(),HintMessage                                            = "2"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #3
0
        private void NewAnArrayWithTypeArgument <T>(T constValue)
        {
            TestNewArray <int[]> testNewArray = new TestNewArray <int[]>();

            testNewArray.Bounds.Add(new InArgument <T>(constValue));

            Variable <int[]> result = new Variable <int[]>()
            {
                Name = "Result"
            };

            testNewArray.Result = result;

            TestSequence seq = new TestSequence
            {
                Variables  = { result },
                Activities =
                {
                    testNewArray,
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).ToString(),HintMessage                                           = new int[1].ToString()
                    },
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).Length.ToString(),HintMessage                                           = constValue.ToString()
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #4
0
        public void NewArrayWithArrayType()
        {
            TestNewArray <Array> arr = new TestNewArray <Array>();

            string error = ErrorStrings.NewArrayRequiresArrayTypeAsResultType;

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>();

            constraints.Add(new TestConstraintViolation(error, arr.ProductActivity));

            TestRuntime.ValidateWorkflowErrors(arr, constraints, error);
        }
コード例 #5
0
        public void NewAnArrayWithTypeArgumentNotIntegral()
        {
            TestNewArray <int[]> testNewArray = new TestNewArray <int[]>();

            testNewArray.Bounds.Add(new InArgument <string>("3"));

            string error = ErrorStrings.NewArrayBoundsRequiresIntegralArguments;

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>();

            constraints.Add(new TestConstraintViolation(error, testNewArray.ProductActivity));

            TestRuntime.ValidateWorkflowErrors(testNewArray, constraints, error);
        }
コード例 #6
0
        public void NewAnArrayWithTypeArgumentULong()
        {
            TestNewArray <int[]> testNewArray = new TestNewArray <int[]>();

            testNewArray.Bounds.Add(new InArgument <ulong>(3));

            string error = string.Format(ErrorStrings.ConstructorInfoNotFound, typeof(int[]).Name);

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>();

            constraints.Add(new TestConstraintViolation(error, testNewArray.ProductActivity));

            TestRuntime.ValidateWorkflowErrors(testNewArray, constraints, error);
        }
コード例 #7
0
        public void InvokeWithWorkflowInvoker()
        {
            TestNewArray <int[]> newArray = new TestNewArray <int[]>()
            {
                Bounds =
                {
                    new InArgument <int>(3),
                },
            };

            IDictionary <string, object> result = WorkflowInvoker.Invoke(newArray.ProductActivity);

            int[] actualResult = (int[])result["Result"];

            if (actualResult.Length != 3)
            {
                throw new Exception("Fail to create int[3]!");
            }
        }
コード例 #8
0
        public void NewArrayWithIncorrectNumberOfParameters()
        {
            TestNewArray <int[]> intArray = new TestNewArray <int[]>
            {
                Bounds =
                {
                    new InArgument <int>(1),
                    new InArgument <int>(2)
                }
            };

            string error = string.Format(ErrorStrings.ConstructorInfoNotFound, typeof(int[]).Name);

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>();

            constraints.Add(new TestConstraintViolation(error, intArray.ProductActivity));

            TestRuntime.ValidateWorkflowErrors(intArray, constraints, error);
        }