Ejemplo n.º 1
0
        public void TryAccessingItemFromAnUninitializedArray()
        {
            Variable <int[]> intArrayVar = new Variable <int[]>()
            {
                Name = "IntVar"
            };

            TestArrayItemValue <int> arrayVal = new TestArrayItemValue <int>
            {
                DisplayName     = "GetValue",
                ArrayVariable   = intArrayVar,
                Index           = 4,
                ExpectedOutcome = Outcome.UncaughtException()
            };

            TestSequence seq = new TestSequence
            {
                Variables  = { intArrayVar },
                Activities =
                {
                    arrayVal
                }
            };

            TestRuntime.RunAndValidateAbortedException(
                seq,
                typeof(InvalidOperationException),
                new Dictionary <string, string>
            {
                { "Message", string.Format(ErrorStrings.MemberCannotBeNull, "Array", arrayVal.ProductActivity.GetType().Name, arrayVal.DisplayName) }
            });
        }
Ejemplo n.º 2
0
        public void AccessValueOfAnItemInOneDimensionalArray()
        {
            Variable <int[]> arrayVariable = new Variable <int[]>("arrayVariable");

            TestArrayItemValue <int> arrayItemValue = new TestArrayItemValue <int> {
                ArrayVariable = arrayVariable, Index = 0
            };

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

            arrayItemValue.Result = result;

            TestSequence seq = new TestSequence
            {
                Variables  = { arrayVariable, result },
                Activities =
                {
                    new TestAssign <int[]> {
                        ToVariable = arrayVariable, ValueExpression = (context => new int[]{                                                  1, 2, 3 })
                    },
                    arrayItemValue,
                    new TestWriteLine      {
                        MessageExpression = e => result.Get(e).ToString(), HintMessage = "1"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
Ejemplo n.º 3
0
        public void SetIndexNull()
        {
            TestArrayItemValue <string> testArray = new TestArrayItemValue <string>
            {
                ArrayExpression = context => new string[] { "x" }
            };
            string errorMessage = string.Format(ErrorStrings.RequiredArgumentValueNotSupplied, "Index");

            TestRuntime.ValidateWorkflowErrors(testArray, new List <TestConstraintViolation>(), typeof(ArgumentException), errorMessage);
        }
Ejemplo n.º 4
0
        public void SetIndexNegative()
        {
            Variable <string[]>         array     = new Variable <string[]>("array", context => new string[] { "Ola" });
            TestArrayItemValue <string> itemValue = new TestArrayItemValue <string>
            {
                ArrayVariable   = array,
                Index           = -1,
                ExpectedOutcome = Outcome.UncaughtException()
            };
            TestSequence testSequence = new TestSequence
            {
                Variables  = { array },
                Activities = { itemValue }
            };

            TestRuntime.RunAndValidateAbortedException(testSequence, typeof(IndexOutOfRangeException), null);
        }
Ejemplo n.º 5
0
        public void TryAccessingItemFromNullArray()
        {
            Variable <string> result = new Variable <string>()
            {
                Name = "Result"
            };

            TestArrayItemValue <string> arrayItem = new TestArrayItemValue <string> {
                Index = 0, Result = result
            };

            TestSequence seq = new TestSequence {
                Variables = { result }, Activities = { arrayItem }
            };

            string errorMessage = string.Format(ErrorStrings.RequiredArgumentValueNotSupplied, "Array");

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>()
            {
                new TestConstraintViolation(errorMessage, arrayItem.ProductActivity, false)
            };

            TestRuntime.ValidateWorkflowErrors(seq, constraints, errorMessage);
        }