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)); }
public void TryGettingValueOfPropertyNameNull() { TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int> { Operand = new PublicType() }; TestRuntime.ValidateInstantiationException(propertyValue, string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propertyValue.DisplayName)); }
public void TryAccessingFieldNotProperty() { PublicType myObj = new PublicType { publicField = "10" }; TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "publicField"); TestRuntime.ValidateInstantiationException(propertyValue, ""); }
public void TryAccessingPropertyWithoutGetter() { PublicType myObj = new PublicType { WriteOnlyProperty = 1 }; TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "WriteOnlyProperty"); TestRuntime.ValidateInstantiationException(propertyValue, ""); }
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) }); }
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); }
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) }); }
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); }
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); }
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); }
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); }
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); }
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 } } }); }
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); }