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); }
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); }
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); }
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); }
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); }
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); }
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]!"); } }
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); }