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); }
public void PropertyNameNull() { TestPropertyReference <PublicType, int> propRef = new TestPropertyReference <PublicType, int> { Operand = new PublicType() }; TestRuntime.ValidateInstantiationException(propRef, string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propRef.DisplayName)); }
public void TrySettingPropertyOfNonExistentProperty() { TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int> { OperandExpression = context => new PublicType(), PropertyName = "NonExistent", }; TrySettingInvalidProperty(propReference, "NonExistent"); }
public void TrySettingPrivatePropertyOnAnObject() { TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int> { OperandExpression = context => new PublicType(), PropertyName = "PrivateProperty", }; TrySettingInvalidProperty(propReference, "PrivateProperty"); }
public void TrySettingFieldNotProperty() { TestPropertyReference <PublicType, int> propReference = new TestPropertyReference <PublicType, int> { OperandExpression = context => new PublicType(), PropertyName = "publicField", }; TrySettingInvalidProperty(propReference, "publicField"); }
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) }); }
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) }); }
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); }
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); }
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); }
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); }
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)); }
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); }