public void CartesianProduct_EmptyValues_ValidateSizeMoreThan()
 {
     AssertValidation.SizeMoreThan(
         s => CombinationUtils.CartesianProduct <int>(new IEnumerable <int> [s]).ToArray(),
         "Values",
         0);
 }
 public void CartesianProduct_0ValueNull_ValidateNotNull0Value()
 {
     AssertValidation.NotNullAll(
         () => CombinationUtils.CartesianProduct <int>(null, new int[0]).ToArray(),
         "Values",
         0);
 }
Beispiel #3
0
        public void ZipWriteOnlyStorer_AddPathNull_ValidateNotNull()
        {
            var storer = new ZipWriteOnlyStorer(false, true);

            AssertValidation.NotNull(
                () => storer.Add(null, 0, 0),
                "Path");
        }
        public void CreateReturnParameterlessMethod_TypeNull_ValidateIsNull()
        {
            Type type = typeof(ClassWithReturnParameterlessMethods <>).MakeGenericType(typeof(int));

            AssertValidation.NotNull(
                () => ReflectionUtils.CreateReturnParameterlessMethodCallback(null, type.GetMethod(StaticMethodName)),
                "Type");
        }
        public void CreateReturnlessOneParameterMethod_MethodInfoNull_ValidateIsNull()
        {
            Type type = typeof(ClassWithReturnlessOneParameterMethods <>).MakeGenericType(typeof(int));

            AssertValidation.NotNull(
                () => ReflectionUtils.CreateReturnlessOneParameterMethodCallback(type, null),
                "MethodInfo");
        }
Beispiel #6
0
        public void ZipWriteOnlyStorer_AddDataNull_ValidateNotNull()
        {
            var storer = new ZipWriteOnlyStorer(false, true);

            AssertValidation.NotNull(
                () => storer.Add("File.data", null),
                "Data");
        }
Beispiel #7
0
        private Constraint ValidateActivitiesConstraint(string runtimeAssembly, PSWorkflowValidationResults validationResults)
        {
            var activityToValidate = new DelegateInArgument <Activity>();
            DelegateInArgument <ValidationContext> delegateInArgument1 = new DelegateInArgument <ValidationContext>();
            Constraint <Activity> constraint = new Constraint <Activity>();
            ActivityAction <Activity, ValidationContext> activityAction = new ActivityAction <Activity, ValidationContext>();

            activityAction.Argument1 = activityToValidate;
            activityAction.Argument2 = delegateInArgument1;
            AssertValidation assertValidation = new AssertValidation();

            assertValidation.IsWarning = false;
            ParameterExpression parameterExpression = Expression.Parameter(typeof(ActivityContext), "env");

            Expression[] expressionArray  = new Expression[3];
            Expression[] expressionArray1 = new Expression[1];
            expressionArray1[0] = parameterExpression;
            expressionArray[0]  = Expression.Call(Expression.Field(Expression.Constant(this), FieldInfo.GetFieldFromHandle(activityToValidate)), (MethodInfo)MethodBase.GetMethodFromHandle(Get, DelegateInArgument <Activity>), expressionArray1);
            expressionArray[1]  = Expression.Field(Expression.Constant(this), FieldInfo.GetFieldFromHandle(runtimeAssembly));
            expressionArray[2]  = Expression.Field(Expression.Constant(this), FieldInfo.GetFieldFromHandle(validationResults));
            ParameterExpression[] parameterExpressionArray = new ParameterExpression[1];
            parameterExpressionArray[0] = parameterExpression;
            assertValidation.Assertion  = new InArgument <bool>(Expression.Lambda <Func <ActivityContext, bool> >(Expression.Call(Expression.Constant(this, typeof(PSWorkflowValidator)), (MethodInfo)MethodBase.GetMethodFromHandle(ValidateActivity), expressionArray), parameterExpressionArray));
            ParameterExpression parameterExpression1 = Expression.Parameter(typeof(ActivityContext), "env");

            Expression[] expressionArray2 = new Expression[3];
            expressionArray2[0] = Expression.Property(null, typeof(CultureInfo).GetProperty("CurrentCulture", BindingFlags.Static));             //TODO: REIVEW: (MethodInfo)MethodBase.GetMethodFromHandle(CultureInfo.get_CurrentCulture));
            expressionArray2[1] = Expression.Property(null, typeof(Resources).GetProperty("InvalidActivity", BindingFlags.Static));              //TODO: REVIEW: (MethodInfo)MethodBase.GetMethodFromHandle(Resources.get_InvalidActivity));
            Expression[] expressionArray3 = new Expression[1];
            Expression[] expressionArray4 = new Expression[1];
            expressionArray4[0] = parameterExpression1;
            expressionArray3[0] = Expression.Property(Expression.Call(Expression.Call(Expression.Field(Expression.Constant(this), FieldInfo.GetFieldFromHandle(PSWorkflowValidator.PSWorkflowValidator.activityToValidate)), (MethodInfo)MethodBase.GetMethodFromHandle(Get, DelegateInArgument <Activity>), expressionArray4), (MethodInfo)MethodBase.GetMethodFromHandle(GetType), new Expression[0]), (MethodInfo)MethodBase.GetMethodFromHandle(get_FullName));
            expressionArray2[2] = Expression.NewArrayInit(typeof(object), expressionArray3);
            ParameterExpression[] parameterExpressionArray1 = new ParameterExpression[1];
            parameterExpressionArray1[0] = parameterExpression1;
            assertValidation.Message     = new InArgument <string>(Expression.Lambda <Func <ActivityContext, string> >(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle(string.Format), expressionArray2), parameterExpressionArray1));
            activityAction.Handler       = assertValidation;
            constraint.Body = activityAction;
            return(constraint);
        }
 public void Find_ListNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (null as LinkedList <int>).Find(i => true),
         "List");
 }
 public void Find_PredicateNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (new LinkedList <int>()).Find(null),
         "Predicate");
 }
Beispiel #10
0
 public void ZipReadOnlyStorer_ReadEntryNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => ZipReadOnlyStorer.FromData(zip32Empty).Read(null),
         "Entry");
 }
 public void ExecuteAndClear_ActionNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (new LinkedList <int>()).ExecuteAndClear(null),
         "Action");
 }
Beispiel #12
0
 public void CreateEnumerable_ParameterCountLessThanZero_ValidateMoreThanOrEquals()
 {
     AssertValidation.MoreThanOrEquals(
         (s) => ReflectionUtils.CreateEnumerable(typeof(List <>), typeof(int), s),
         "ParametersCount", 0);
 }
Beispiel #13
0
 public void Split_NullSeparators_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => StringUtils.Split("", null).Count(),
         "Separators");
 }
Beispiel #14
0
        private static Constraint ConfirmWithNoTarget()
        {
            DelegateInArgument <Confirm> element = new DelegateInArgument <Confirm> {
                Name = "element"
            };
            DelegateInArgument <ValidationContext> argument = new DelegateInArgument <ValidationContext> {
                Name = "validationContext"
            };
            Variable <bool> assertFlag = new Variable <bool> {
                Name = "assertFlag"
            };
            Variable <IEnumerable <Activity> > elements = new Variable <IEnumerable <Activity> > {
                Name = "elements"
            };
            Variable <int> index = new Variable <int> {
                Name = "index"
            };
            Constraint <Confirm> constraint = new Constraint <Confirm>();
            ActivityAction <Confirm, ValidationContext> action = new ActivityAction <Confirm, ValidationContext> {
                Argument1 = element,
                Argument2 = argument
            };
            Sequence sequence = new Sequence {
                Variables = { assertFlag, elements, index }
            };
            If item = new If {
                Condition = new InArgument <bool>(env => element.Get(env).Target != null)
            };
            Assign <bool> assign = new Assign <bool> {
                To    = assertFlag,
                Value = 1
            };

            item.Then = assign;
            Sequence sequence2 = new Sequence();
            Assign <IEnumerable <Activity> > assign2 = new Assign <IEnumerable <Activity> > {
                To = elements
            };
            GetParentChain chain = new GetParentChain {
                ValidationContext = argument
            };

            assign2.Value = chain;
            sequence2.Activities.Add(assign2);
            While         @while    = new While(env => !assertFlag.Get(env) && (index.Get(env) < elements.Get(env).Count <Activity>()));
            Sequence      sequence3 = new Sequence();
            If            if2       = new If(env => elements.Get(env).ElementAt <Activity>(index.Get(env)).GetType() == typeof(CompensationParticipant));
            Assign <bool> assign3   = new Assign <bool> {
                To    = assertFlag,
                Value = 1
            };

            if2.Then = assign3;
            sequence3.Activities.Add(if2);
            Assign <int> assign4 = new Assign <int> {
                To    = index,
                Value = new InArgument <int>(env => index.Get(env) + 1)
            };

            sequence3.Activities.Add(assign4);
            @while.Body = sequence3;
            sequence2.Activities.Add(@while);
            item.Else = sequence2;
            sequence.Activities.Add(item);
            AssertValidation validation = new AssertValidation {
                Assertion = new InArgument <bool>(assertFlag),
                Message   = new InArgument <string>(System.Activities.SR.ConfirmWithNoTargetConstraint)
            };

            sequence.Activities.Add(validation);
            action.Handler  = sequence;
            constraint.Body = action;
            return(constraint);
        }
Beispiel #15
0
 public void CreateEnumerable_EnumerableGTDNull_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => ReflectionUtils.CreateEnumerable(null, typeof(int), 0),
         "EnumerableGTD");
 }
 public void Select1D_ArrayNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (null as int[]).Select((v, i) => v),
         "Source");
 }
 public void Select1D_SelectorNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (new int[0]).Select <int, long>(null),
         "Selector");
 }
 public void Clone2D_ArrayNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => ArrayUtils.Clone(null as int[, ]),
         "Source");
 }
 public void CreateSetAccessorProperty_TypeNull_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => ReflectionUtils.CreateSetAccessor(null, typeof(ClassWithProperties <>).MakeGenericType(typeof(object)).GetProperty(StaticFieldName)),
         "Type");
 }
 public void CreateGetAccessorProperty_PropertyInfoNull_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => ReflectionUtils.CreateGetAccessor(this.GetType(), null as PropertyInfo),
         "PropertyInfo");
 }
 public void ToArray_ListNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (null as LinkedList <int>).ToArray(),
         "List");
 }
Beispiel #22
0
 public void Deserialize_DataNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => formatter.Deserialize <int>(null),
         "Data");
 }
        private Constraint ProcessChildSubtreeConstraints()
        {
            DelegateInArgument <TransactedReceiveScope> argument = new DelegateInArgument <TransactedReceiveScope> {
                Name = "element"
            };
            DelegateInArgument <ValidationContext> argument2 = new DelegateInArgument <ValidationContext> {
                Name = "validationContext"
            };
            DelegateInArgument <Activity> child = new DelegateInArgument <Activity> {
                Name = "child"
            };
            Variable <bool> nestedCompensableActivity = new Variable <bool> {
                Name = "nestedCompensableActivity"
            };
            Constraint <TransactedReceiveScope> constraint = new Constraint <TransactedReceiveScope>();
            ActivityAction <TransactedReceiveScope, ValidationContext> action = new ActivityAction <TransactedReceiveScope, ValidationContext> {
                Argument1 = argument,
                Argument2 = argument2
            };
            Sequence sequence = new Sequence {
                Variables = { nestedCompensableActivity }
            };
            ForEach <Activity> item    = new ForEach <Activity>();
            GetChildSubtree    subtree = new GetChildSubtree {
                ValidationContext = argument2
            };

            item.Values = subtree;
            ActivityAction <Activity> action2 = new ActivityAction <Activity> {
                Argument = child
            };
            Sequence sequence2             = new Sequence();
            If       @if                   = new If();
            Equal <Type, Type, bool> equal = new Equal <Type, Type, bool>();
            ObtainType type                = new ObtainType {
                Input = new InArgument <Activity>(child)
            };

            equal.Left    = type;
            equal.Right   = new InArgument <Type>(context => typeof(System.Activities.Statements.TransactionScope));
            @if.Condition = equal;
            AssertValidation validation = new AssertValidation {
                IsWarning = 1
            };
            NestedChildTransactionScopeActivityAbortInstanceFlagValidator validator = new NestedChildTransactionScopeActivityAbortInstanceFlagValidator {
                Child = child
            };

            validation.Assertion    = validator;
            validation.Message      = new InArgument <string>(env => System.ServiceModel.Activities.SR.AbortInstanceOnTransactionFailureDoesNotMatch(child.Get(env).DisplayName, this.DisplayName));
            validation.PropertyName = "AbortInstanceOnTransactionFailure";
            @if.Then = validation;
            sequence2.Activities.Add(@if);
            If if2 = new If();
            Equal <Type, Type, bool> equal2 = new Equal <Type, Type, bool>();
            ObtainType type2 = new ObtainType {
                Input = new InArgument <Activity>(child)
            };

            equal2.Left   = type2;
            equal2.Right  = new InArgument <Type>(context => typeof(CompensableActivity));
            if2.Condition = equal2;
            Assign <bool> assign = new Assign <bool> {
                To    = new OutArgument <bool>(nestedCompensableActivity),
                Value = new InArgument <bool>(true)
            };

            if2.Then = assign;
            sequence2.Activities.Add(if2);
            action2.Handler = sequence2;
            item.Body       = action2;
            sequence.Activities.Add(item);
            AssertValidation validation2 = new AssertValidation {
                Assertion    = new InArgument <bool>(env => !nestedCompensableActivity.Get(env)),
                Message      = new InArgument <string>(System.ServiceModel.Activities.SR.CompensableActivityInsideTransactedReceiveScope),
                PropertyName = "Body"
            };

            sequence.Activities.Add(validation2);
            action.Handler  = sequence;
            constraint.Body = action;
            return(constraint);
        }
Beispiel #24
0
 public void QuickSortArrayAndAssociatedArray_AssociatedArray0ArrayNull_ValidateIsNull()
 {
     AssertValidation.NotNullAll(
         () => SortUtils.QuickSort(true, elementComparer, new Element[6], null as Element[], new Element[6]),
         "AssociatedLists", 0);
 }
Beispiel #25
0
 public void CreateEnumerable_ElementTypeNull_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => ReflectionUtils.CreateEnumerable(typeof(List <>), null, 0),
         "ElementType");
 }
Beispiel #26
0
 public void QuickSortArrayAndAssociatedArray_ListDifferentSizes_ValidateIsSizesEquals()
 {
     AssertValidation.SizesEquals(
         () => SortUtils.QuickSort(true, elementComparer, new Element[3], new Element[6], new Element[6]),
         "List", "AssociatedLists", 0, 3, 6);
 }
Beispiel #27
0
 public void Split_NullInputString_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => StringUtils.Split(null, '\n').Count(),
         "InputString");
 }
 public void ExecuteAndClear_ListNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => (null as LinkedList <int>).ExecuteAndClear(i => {}),
         "List");
 }
Beispiel #29
0
 public void QuickSortOnlyArray_ArrayNull_ValidateIsNull()
 {
     AssertValidation.NotNull(
         () => SortUtils.QuickSort(true, elementComparer, null),
         "List");
 }
Beispiel #30
0
 public void ZipReadOnlyStorer_FromDataNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => ZipReadOnlyStorer.FromData(null),
         "Data");
 }