public void ActivityHelper_InjectExpression_Dev2SwitchIsNull_ReturnNull() { //---------------Set up test pack------------------- var viewModel = new DecisionDesignerViewModel(CreateModelItem()); var dev2DecisionStack = new Dev2DecisionStack() { DisplayText = "", FalseArmText = "", TrueArmText = "", Version = "2", Mode = Dev2DecisionMode.AND }; dev2DecisionStack.TheStack = new List <Dev2Decision>(); var decisionExpressionMessage = new ConfigureDecisionExpressionMessage(); viewModel.Handle(decisionExpressionMessage); var mySwitch = new Dev2Switch(); mySwitch = null; var expressionText1 = string.Join("", GlobalConstants.InjectedSwitchDataFetch, "(\"", "aaaaaaa", "\",", GlobalConstants.InjectedDecisionDataListVariable, ")"); var expressionText = viewModel.ModelItem.Properties[expressionText1]; //------------Setup for test-------------------------- var expr = ActivityHelper.InjectExpression(mySwitch, expressionText); Assert.IsNull(expr); }
public static string ConfigureDecisionExpression(ConfigureDecisionExpressionMessage args) { var condition = ConfigureActivity <DsfFlowDecisionActivity>(args.ModelItem, GlobalConstants.ConditionPropertyText, args.IsNew, args.IsPaste); if (condition == null) { return(null); } var expression = condition.Properties[GlobalConstants.ExpressionPropertyText]; _callBackHandler = StartDecisionWizard(condition); if (_callBackHandler != null) { try { var tmp = FlowNodeHelper.CleanModelData(_callBackHandler.ModelData); var dds = JsonConvert.DeserializeObject <Dev2DecisionStack>(tmp); if (dds == null) { return(null); } ActivityHelper.SetArmTextDefaults(dds); var expr = ActivityHelper.InjectExpression(dds, expression); ActivityHelper.SetArmText(args.ModelItem, dds); ActivityHelper.SetDisplayName(args.ModelItem, dds); // PBI 9220 - 2013.04.29 - TWR return(expr); } catch { // } } return(null); }
public void ActivityHelper_Dev2Decision_Null_TrueArmText_SetArmText() { //---------------Set up test pack------------------- using (var viewModel = new DecisionDesignerViewModel(CreateModelItem())) { var dev2DecisionStack = new Dev2DecisionStack { DisplayText = "", FalseArmText = "", TrueArmText = null, Version = "2", Mode = Dev2DecisionMode.AND, TheStack = new List <Dev2Decision>() }; var decisionExpressionMessage = new ConfigureDecisionExpressionMessage(); viewModel.Handle(decisionExpressionMessage); //------------Setup for test-------------------------- ActivityHelper.SetArmTextDefaults(dev2DecisionStack); Assert.AreEqual("True", dev2DecisionStack.TrueArmText); } }
// ReSharper disable InconsistentNaming public void FlowController_HandleConfigureDecisionExpressionMessageAndIsNewTrue_WizardNotShown() // ReSharper restore InconsistentNaming { #region setup first Mock ModelItem var env = EnviromentRepositoryTest.CreateMockEnvironment(); var properties = new Dictionary <string, Mock <ModelProperty> >(); var propertyCollection = new Mock <ModelPropertyCollection>(); var testAct = new DsfFlowDecisionActivity { ExpressionText = "Not Null Test Value" }; var prop = new Mock <ModelProperty>(); prop.Setup(p => p.ComputedValue).Returns(testAct); properties.Add("Condition", prop); propertyCollection.Protected().Setup <ModelProperty>("Find", "Condition", true).Returns(prop.Object); var source = new Mock <ModelItem>(); source.Setup(s => s.Properties).Returns(propertyCollection.Object); #endregion #region setup decision Mock ModelItem var crmDecision = new Mock <IContextualResourceModel>(); crmDecision.Setup(r => r.Environment).Returns(env.Object); crmDecision.Setup(r => r.ResourceName).Returns("Test"); crmDecision.Setup(res => res.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.xmlServiceDefinition)); var decisionProperties = new Dictionary <string, Mock <ModelProperty> >(); var decisionPropertyCollection = new Mock <ModelPropertyCollection>(); var decisionProp = new Mock <ModelProperty>(); decisionProp.Setup(p => p.ComputedValue).Returns(string.Empty); decisionProperties.Add("Condition", decisionProp); decisionPropertyCollection.Protected().Setup <ModelProperty>("Find", "Condition", true).Returns(decisionProp.Object); var decisionModelItem = new Mock <ModelItem>(); decisionModelItem.Setup(s => s.Properties).Returns(decisionPropertyCollection.Object); decisionModelItem.Setup(s => s.ItemType).Returns(typeof(FlowDecision)); prop.Setup(p => p.Value).Returns(decisionModelItem.Object); #endregion #region setup Environment Model env.Setup(c => c.Connection).Returns(new Mock <IEnvironmentConnection>().Object); #endregion var flowController = new FlowController(new Mock <IPopupController>().Object); var message = new ConfigureDecisionExpressionMessage { ModelItem = source.Object, EnvironmentModel = env.Object, IsNew = true }; flowController.Handle(message); }
public void ActivityHelper_InjectExpression_Dev2Switch() { //---------------Set up test pack------------------- var serializer = new Dev2JsonSerializer(); var viewModel = new DecisionDesignerViewModel(CreateModelItem()); var dev2DecisionStack = new Dev2DecisionStack() { DisplayText = "", FalseArmText = "", TrueArmText = "", Version = "2", Mode = Dev2DecisionMode.AND }; dev2DecisionStack.TheStack = new List <Dev2Decision>(); var decisionExpressionMessage = new ConfigureDecisionExpressionMessage(); viewModel.Handle(decisionExpressionMessage); var mySwitch = new Dev2Switch(); //------------Setup for test-------------------------- var testAct = new DsfFlowSwitchActivity { ExpressionText = "" }; var prop = new Mock <ModelProperty>(); prop.Setup(p => p.ComputedValue).Returns(testAct); ActivityHelper.InjectExpression(mySwitch, prop.Object); //------------Assert Results------------------------- var act = new DsfDecision { Conditions = dev2DecisionStack, And = true }; var stateItems = act.GetState(); Assert.AreEqual(5, stateItems.Count()); var expectedResults = new[] { new StateVariable { Name = "Conditions", Type = StateVariable.StateType.Input, Value = serializer.Serialize(dev2DecisionStack) }, new StateVariable { Name = "And", Type = StateVariable.StateType.Input, Value = "True" }, new StateVariable { Name = "Result", Type = StateVariable.StateType.Output, Value = null }, new StateVariable { Name = "TrueArm", Type = StateVariable.StateType.Output, Value = ActivityHelper.GetSerializedStateValueFromCollection(act.TrueArm?.ToList()) }, new StateVariable { Name = "FalseArm", Type = StateVariable.StateType.Output, Value = ActivityHelper.GetSerializedStateValueFromCollection(act.FalseArm?.ToList()) } }; var iter = act.GetState().Select((item, index) => new { value = item, expectValue = expectedResults[index] }); Assert.AreEqual(expectedResults.Length, iter.Count()); foreach (var entry in iter) { Assert.AreEqual(entry.expectValue.Name, entry.value.Name); Assert.AreEqual(entry.expectValue.Type, entry.value.Type); Assert.AreEqual(entry.expectValue.Value, entry.value.Value); } }
// ReSharper disable once UnusedParameter.Global public void Handle(ConfigureDecisionExpressionMessage message) { ShowLarge = true; }