예제 #1
0
        public void SetPublicPropertyOnAnObject()
        {
            Variable <CoreWf.Statements.Sequence> customType = new Variable <CoreWf.Statements.Sequence>()
            {
                Name = "Custom"
            };

            TestPropertyReference <CoreWf.Statements.Sequence, string> propReference = new TestPropertyReference <CoreWf.Statements.Sequence, string> {
                OperandVariable = customType, PropertyName = "DisplayName"
            };

            TestSequence seq = new TestSequence
            {
                Variables  = { customType },
                Activities =
                {
                    new TestAssign <CoreWf.Statements.Sequence> {
                        ToVariable = customType, ValueExpression = (context => new CoreWf.Statements.Sequence()
                        {
                            DisplayName = "MySequence"
                        })
                    },
                    new TestAssign <string>                     {
                        ToLocation = propReference, Value = "NotMySequence"
                    },
                    new TestWriteLine                           {
                        MessageExpression = e => customType.Get(e).DisplayName, HintMessage = "NotMySequence"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
예제 #2
0
        public void PropertyNameNull()
        {
            TestPropertyReference <PublicType, int> propRef = new TestPropertyReference <PublicType, int>
            {
                Operand = new PublicType()
            };

            TestRuntime.ValidateInstantiationException(propRef, string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propRef.DisplayName));
        }
예제 #3
0
        public void TrySettingPropertyOfNonExistentProperty()
        {
            TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int>
            {
                OperandExpression = context => new PublicType(),
                PropertyName      = "NonExistent",
            };

            TrySettingInvalidProperty(propReference, "NonExistent");
        }
예제 #4
0
        public void TrySettingPrivatePropertyOnAnObject()
        {
            TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int>
            {
                OperandExpression = context => new PublicType(),
                PropertyName      = "PrivateProperty",
            };

            TrySettingInvalidProperty(propReference, "PrivateProperty");
        }
예제 #5
0
        public void TrySettingFieldNotProperty()
        {
            TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int>
            {
                OperandExpression = context => new PublicType(),
                PropertyName      = "publicField",
            };

            TrySettingInvalidProperty(propReference, "publicField");
        }
예제 #6
0
        public void ConstraintErrorForNullPropertyName()
        {
            TestPropertyReference <PublicType, int> propertyRef = new TestPropertyReference <PublicType, int>
            {
                OperandExpression = context => new PublicType()
            };

            TestExpressionTracer.Validate(propertyRef, new List <string> {
                string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propertyRef.DisplayName)
            });
        }
예제 #7
0
        public void ConstraintErrorForInvalidProperty()
        {
            TestPropertyReference <PublicType, int> propertyRef = new TestPropertyReference <PublicType, int>
            {
                OperandExpression = context => new PublicType(),
                PropertyName      = "Invalid"
            };

            TestExpressionTracer.Validate(propertyRef, new List <string> {
                string.Format(ErrorStrings.MemberNotFound, "Invalid", typeof(PublicType).Name)
            });
        }
예제 #8
0
        private void TrySettingInvalidProperty(TestPropertyReference <PublicType, int> propRef, string propName)
        {
            TestAssign <int> assign = new TestAssign <int> {
                ToLocation = propRef, Value = 10, ExpectedOutcome = Outcome.UncaughtException()
            };

            string error = string.Format(ErrorStrings.MemberNotFound, propName, typeof(PublicType).Name);

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

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

            TestRuntime.ValidateWorkflowErrors(assign, constraints, error);
        }
예제 #9
0
        public void ConstraintErrorForEnumOperand()
        {
            WeekDay weekday = WeekDay.Monday;

            TestPropertyReference <WeekDay, int> propRef = new TestPropertyReference <WeekDay, int> {
                Operand = weekday, PropertyName = "Monday"
            };

            List <string> errors = new List <string>
            {
                string.Format(ErrorStrings.TargetTypeCannotBeEnum, propRef.ProductActivity.GetType().Name, propRef.DisplayName),
                string.Format(ErrorStrings.MemberNotFound, "Monday", typeof(WeekDay).Name)
            };

            TestExpressionTracer.Validate(propRef, errors);
        }
예제 #10
0
        public void SetStaticPropertyOnAnObject()
        {
            TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int> {
                PropertyName = "StaticProperty"
            };

            TestSequence seq = new TestSequence
            {
                Activities =
                {
                    new TestAssign <int> {
                        ToLocation = propReference, Value = 110
                    },
                    new TestWriteLine    {
                        MessageExpression = e => PublicType.StaticProperty.ToString(), HintMessage = "110"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
예제 #11
0
        public void SetPublicPropertyOnAStruct()
        {
            TheStruct myStruct = new TheStruct {
                PublicProperty = 23
            };
            Variable <TheStruct> customType = new Variable <TheStruct>()
            {
                Name = "Custom", Default = myStruct
            };

            TestPropertyReference <TheStruct, int> propReference = new TestPropertyReference <TheStruct, int>
            {
                OperandVariable = customType,
                PropertyName    = "PublicProperty"
            };

            TestSequence seq = new TestSequence
            {
                Variables  = { customType },
                Activities =
                {
                    new TestAssign <int> {
                        ToLocation = propReference, Value = 27
                    },
                    new TestWriteLine    {
                        MessageExpression = e => customType.Get(e).publicField.ToString(), HintMessage = "0"
                    }
                }
            };

            string error = string.Format(ErrorStrings.TargetTypeIsValueType, typeof(PropertyReference <TheStruct, int>).Name, propReference.DisplayName);

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

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

            TestRuntime.ValidateWorkflowErrors(seq, constraints, error);
        }
예제 #12
0
        public void PassEnumTypeAsOperand()
        {
            TestPropertyReference <WeekDay, int> propertyRef = new TestPropertyReference <WeekDay, int>
            {
                Operand      = WeekDay.Monday,
                PropertyName = "Monday"
            };

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>
            {
                new TestConstraintViolation(
                    string.Format(ErrorStrings.TargetTypeCannotBeEnum, propertyRef.ProductActivity.GetType().Name, propertyRef.DisplayName),
                    propertyRef.ProductActivity),
                new TestConstraintViolation(
                    string.Format(ErrorStrings.MemberNotFound, "Monday", typeof(WeekDay).Name),
                    propertyRef.ProductActivity)
            };

            TestRuntime.ValidateWorkflowErrors(
                propertyRef,
                constraints,
                string.Format(ErrorStrings.TargetTypeCannotBeEnum, propertyRef.ProductActivity.GetType().Name, propertyRef.DisplayName));
        }
예제 #13
0
        public void ThrowExceptionFromSetterOFCustomTypeProperty()
        {
            Variable <ExceptionThrowingSetterAndGetter> customType = new Variable <ExceptionThrowingSetterAndGetter>("Custom", context => new ExceptionThrowingSetterAndGetter());

            TestPropertyReference <ExceptionThrowingSetterAndGetter, int> propReference = new TestPropertyReference <ExceptionThrowingSetterAndGetter, int>
            {
                OperandVariable = customType,
                PropertyName    = "ExceptionThrowingProperty",
            };

            TestSequence seq = new TestSequence
            {
                Variables  = { customType },
                Activities =
                {
                    new TestAssign <int> {
                        ToLocation = propReference, Value = 10, ExpectedOutcome = Outcome.UncaughtException()
                    },
                }
            };

            TestRuntime.RunAndValidateAbortedException(seq, typeof(IndexOutOfRangeException), null);
        }