Exemple #1
0
        public void TryAccessPrivatePropertyOnAnObject()
        {
            PublicType myObj = new PublicType();

            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "PrivateProperty");

            TestRuntime.ValidateInstantiationException(propertyValue, string.Format(ErrorStrings.MemberNotFound, "PrivateProperty", typeof(PublicType).Name));
        }
Exemple #2
0
        public void TryGettingValueOfPropertyNameNull()
        {
            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>
            {
                Operand = new PublicType()
            };

            TestRuntime.ValidateInstantiationException(propertyValue, string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propertyValue.DisplayName));
        }
Exemple #3
0
        public void TryAccessingFieldNotProperty()
        {
            PublicType myObj = new PublicType {
                publicField = "10"
            };

            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "publicField");

            TestRuntime.ValidateInstantiationException(propertyValue, "");
        }
Exemple #4
0
        public void TryAccessingPropertyWithoutGetter()
        {
            PublicType myObj = new PublicType {
                WriteOnlyProperty = 1
            };

            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "WriteOnlyProperty");

            TestRuntime.ValidateInstantiationException(propertyValue, "");
        }
Exemple #5
0
        public void ConstraintErrorForPropertyNameNull()
        {
            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>
            {
                OperandExpression = context => new PublicType()
            };

            TestExpressionTracer.Validate(propertyValue, new List <string> {
                string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propertyValue.DisplayName)
            });
        }
Exemple #6
0
        public void ThrowExceptionFromGetterOFCustomTypeProperty()
        {
            TestPropertyValue <ExceptionThrowingSetterAndGetter, int> propertyValue = new TestPropertyValue <ExceptionThrowingSetterAndGetter, int>
            {
                OperandExpression = context => new ExceptionThrowingSetterAndGetter(),
                PropertyName      = "ExceptionThrowingProperty",
                ExpectedOutcome   = Outcome.UncaughtException()
            };

            TestRuntime.RunAndValidateAbortedException(propertyValue, typeof(IndexOutOfRangeException), null);
        }
Exemple #7
0
        public void ConstraintErrorForInvalidProperty()
        {
            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>
            {
                OperandExpression = context => new PublicType(),
                PropertyName      = "Invalid"
            };

            TestExpressionTracer.Validate(propertyValue, new List <string> {
                string.Format(ErrorStrings.MemberNotFound, "Invalid", typeof(PublicType).Name)
            });
        }
Exemple #8
0
        public void set_property_should_update_action_model_properties()
        {
            // arrange
            var actionMethod = typeof(object).GetRuntimeMethod(nameof(object.ToString), EmptyTypes);
            var action       = new ActionModel(actionMethod, new object[0]);
            var value        = new TestPropertyValue();

            // act
            action.SetProperty(value);

            // assert
            action.GetProperty <TestPropertyValue>().Should().BeSameAs(value);
        }
Exemple #9
0
        public void set_property_should_update_controller_model_properties()
        {
            // arrange
            var controllerType = typeof(object).GetTypeInfo();
            var controller     = new ControllerModel(controllerType, new object[0]);
            var value          = new TestPropertyValue();

            // act
            controller.SetProperty(value);

            // assert
            controller.GetProperty <TestPropertyValue>().Should().BeSameAs(value);
        }
Exemple #10
0
        public void AccessPublicPropertyOnAStruct()
        {
            TheStruct myStruct = new TheStruct {
                PublicProperty = 22
            };

            TestPropertyValue <TheStruct, int> propValue = new TestPropertyValue <TheStruct, int> {
                Operand = myStruct, PropertyName = "PublicProperty"
            };

            TestSequence seq = TestExpressionTracer.GetTraceablePropertyValue <TheStruct, int>(propValue, myStruct.PublicProperty.ToString());

            TestRuntime.RunAndValidateWorkflow(seq);
        }
Exemple #11
0
        public void AccessPublicPropertyOnAnObject()
        {
            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>
            {
                OperandExpression = context => new PublicType()
                {
                    PublicProperty = 10
                },
                PropertyName = "PublicProperty",
            };

            TestSequence seq = TestExpressionTracer.GetTraceablePropertyValue <PublicType, int>(propertyValue, "10");

            TestRuntime.RunAndValidateWorkflow(seq);
        }
Exemple #12
0
        public void ConstraintErrorForEnumOperand()
        {
            WeekDay weekday = WeekDay.Monday;

            TestPropertyValue <WeekDay, int> propValue = new TestPropertyValue <WeekDay, int> {
                Operand = weekday, PropertyName = "Monday"
            };

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

            TestExpressionTracer.Validate(propValue, errors);
        }
Exemple #13
0
        public void PassEnumTypeAsOperand()
        {
            WeekDay weekday = WeekDay.Monday;

            TestPropertyValue <WeekDay, int> propValue = new TestPropertyValue <WeekDay, int> {
                Operand = weekday, PropertyName = "Monday"
            };

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

            constraints.Add(new TestConstraintViolation(
                                string.Format(ErrorStrings.TargetTypeCannotBeEnum, propValue.ProductActivity.GetType().Name, propValue.DisplayName),
                                propValue.ProductActivity));
            constraints.Add(new TestConstraintViolation(
                                string.Format(ErrorStrings.MemberNotFound, "Monday", typeof(WeekDay).Name),
                                propValue.ProductActivity));

            TestRuntime.ValidateWorkflowErrors(propValue,
                                               constraints,
                                               string.Format(ErrorStrings.TargetTypeCannotBeEnum, propValue.ProductActivity.GetType().Name, propValue.DisplayName));
        }
        public static TestSequence GetTraceablePropertyValue <TOperand, TResult>(TestPropertyValue <TOperand, TResult> propertyValue, string expectedResult)
        {
            Variable <TResult> result = new Variable <TResult>()
            {
                Name = "Result"
            };

            propertyValue.Result = result;

            return(new TestSequence
            {
                Variables = { result },
                Activities =
                {
                    propertyValue,
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).ToString(),HintMessage                                          = expectedResult
                    }
                }
            });
        }
Exemple #15
0
        public void AccessStaticPropertyOnAnObject()
        {
            TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int> {
                PropertyName = "StaticProperty"
            };
            TestSequence seq = new TestSequence()
            {
                Activities =
                {
                    new TestAssign <int>
                    {
                        ToLocation = new TestPropertyReference <PublicType, int>{
                            PropertyName = "StaticProperty"
                        },
                        Value = 10
                    },
                    TestExpressionTracer.GetTraceablePropertyValue <PublicType, int>(propertyValue, "10")
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }