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) } }); }
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); }
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); }
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); }
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); }