public DecisionDesignerViewModel(ModelItem modelItem)
            : base(modelItem)
        {
            AddTitleBarLargeToggle();
            Collection = new ObservableCollection <IDev2TOFn>();
            Collection.CollectionChanged += CollectionCollectionChanged;
            var collection = FindRecsetOptions.FindAllDecision().Select(c => c.HandlesType());

            WhereOptions             = new ObservableCollection <string>(collection);
            SearchTypeUpdatedCommand = new DelegateCommand(OnSearchTypeChanged);
            _isInitializing          = true;
            ConfigureDecisionExpression(ModelItem);
            InitializeItems(Tos);
            DeleteCommand = new DelegateCommand(x =>
            {
                DeleteRow(x as DecisionTO);
            });
            _isInitializing = false;
            if (DisplayText != DisplayName)
            {
                DisplayName = DisplayText;
            }
            if (string.IsNullOrEmpty(DisplayName) || DisplayName == "Decision")
            {
                DisplayName = "Decision";
                DisplayText = DisplayName;
            }
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_Flow_Decision;
        }
Example #2
0
        public void FindRecsetOptions_FindAll_GetAllRecsetOptions_RightNumberOfOptionsAndCorrectOrder()
        {
            //------------Setup for test--------------------------
            ObservableCollection <string> expected = GlobalConstants.FindRecordsOperations.ToObservableCollection();
            //------------Execute Test---------------------------
            var actual = new ObservableCollection <string>(FindRecsetOptions.FindAll().Select(c => c.HandlesType()));

            //------------Assert Results-------------------------
            CollectionAssert.AreEqual(expected, actual, "The order of the find records drop down is wrong");
        }
Example #3
0
        public void OnSearchTypeChanged()
        {
            UpdateMatchVisibility(_assertOp, _findRecsetOptions ?? FindRecsetOptions.FindAllDecision());

            var requiresCriteria = _requiresSearchCriteria.Contains(_assertOp);

            IsSearchCriteriaEnabled = requiresCriteria;
            if (!requiresCriteria)
            {
                Value = string.Empty;
            }
        }
        public FindRecordsMultipleCriteriaDesignerViewModel(ModelItem modelItem)
            : base(modelItem)
        {
            AddTitleBarLargeToggle();

            WhereOptions             = new ObservableCollection <string>(FindRecsetOptions.FindAll().Select(c => c.HandlesType()));
            SearchTypeUpdatedCommand = new DelegateCommand(OnSearchTypeChanged);

            dynamic mi = ModelItem;

            InitializeItems(mi.ResultsCollection);
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_Recordset_Find_Records;
        }
Example #5
0
        public ServiceTestOutput(string variable, string value, string from, string to)
        {
            Variable           = variable ?? throw new ArgumentNullException(nameof(variable));
            Value              = value;
            From               = from;
            To                 = to;
            _findRecsetOptions = FindRecsetOptions.FindAllDecision();
            var collection = _findRecsetOptions.Select(c => c.HandlesType());

            AssertOps       = new ObservableCollection <string>(collection);
            AssertOp        = "=";
            CanEditVariable = true;
            IsSinglematchCriteriaVisible = true;
            TestPending = true;
        }
Example #6
0
        Func <DataStorage.WarewolfAtom, bool> CreateFuncFromOperator(string searchType, IEnumerable <DataStorage.WarewolfAtom> values, IEnumerable <DataStorage.WarewolfAtom> from, IEnumerable <DataStorage.WarewolfAtom> to)
        {
            var opt = FindRecsetOptions.FindMatch(searchType);

            return((a) =>
            {
                try
                {
                    return opt.GenerateFunc(values, from, to, RequireAllFieldsToMatch).Invoke(a);
                }
                catch (DataStorage.WarewolfInvalidComparisonException ex)
                {
                    return false;
                }
            });
        }
        public void DecisionDisplayHelper_GetValue_ShouldMatchToRsOpHandleTypes()
        {
            //------------Setup for test--------------------------
            var allOptions = FindRecsetOptions.FindAllDecision();
            var allMatched = true;

            //------------Execute Test---------------------------
            foreach (var findRecsetOptionse in allOptions)
            {
                var decisionType = DecisionDisplayHelper.GetValue(findRecsetOptionse.HandlesType());
                if (decisionType == enDecisionType.Choose)
                {
                    allMatched = false;
                    Assert.Fail($"{findRecsetOptionse.HandlesType()} not found");
                }
            }
            //------------Assert Results-------------------------
            Assert.IsTrue(allMatched);
        }
        Func <DataASTMutable.WarewolfAtom, bool> CreateFuncFromOperator(string searchType, IEnumerable <DataASTMutable.WarewolfAtom> values, IEnumerable <DataASTMutable.WarewolfAtom> from, IEnumerable <DataASTMutable.WarewolfAtom> to)
        {
            IFindRecsetOptions opt = FindRecsetOptions.FindMatch(searchType);

            return(opt.GenerateFunc(values, from, to, RequireAllFieldsToMatch));
        }
Example #9
0
 public DsfFindRecordsActivityDesigner()
 {
     InitializeComponent();
     ItemList             = FindRecsetOptions.FindAll().Select(c => c.HandlesType()).ToList();
     cbxWhere.ItemsSource = ItemList.OrderBy(c => c);
 }
Example #10
0
        private static IEnumerable <TestRunResult> GetTestRunResults(IDSFDataObject dataObject, IServiceTestOutput output, Dev2DecisionFactory factory, IDebugState debugState)
        {
            if (output == null)
            {
                var testResult = new TestRunResult
                {
                    RunTestResult = RunResult.None
                };
                return(new List <TestRunResult> {
                    testResult
                });
            }
            if (string.IsNullOrEmpty(output.Variable) && string.IsNullOrEmpty(output.Value))
            {
                var testResult = new TestRunResult
                {
                    RunTestResult = RunResult.None
                };
                output.Result = testResult;
                return(new List <TestRunResult> {
                    testResult
                });
            }
            if (output.Result != null)
            {
                output.Result.RunTestResult = RunResult.TestInvalid;
            }
            if (string.IsNullOrEmpty(output.Variable))
            {
                var testResult = new TestRunResult
                {
                    RunTestResult = RunResult.TestInvalid,
                    Message       = Messages.Test_NothingToAssert
                };
                output.Result = testResult;
                if (dataObject.IsDebugMode())
                {
                    var       debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(testResult.Message, true);
                    DebugItem itemToAdd = new DebugItem();
                    itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());
                    debugState.AssertResultList.Add(itemToAdd);
                }
                return(new List <TestRunResult> {
                    testResult
                });
            }
            IFindRecsetOptions opt = FindRecsetOptions.FindMatch(output.AssertOp);
            var decisionType       = DecisionDisplayHelper.GetValue(output.AssertOp);
            var value = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.Value)
            };
            var from = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.From)
            };
            var to = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.To)
            };

            IList <TestRunResult> ret = new List <TestRunResult>();
            var iter  = new WarewolfListIterator();
            var cols1 = dataObject.Environment.EvalAsList(DataListUtil.AddBracketsToValueIfNotExist(output.Variable), 0);
            var c1    = new WarewolfAtomIterator(cols1);
            var c2    = new WarewolfAtomIterator(value);
            var c3    = new WarewolfAtomIterator(@from);

            if (opt.ArgumentCount > 2)
            {
                c2 = new WarewolfAtomIterator(to);
            }
            iter.AddVariableToIterateOn(c1);
            iter.AddVariableToIterateOn(c2);
            iter.AddVariableToIterateOn(c3);
            while (iter.HasMoreData())
            {
                var val1         = iter.FetchNextValue(c1);
                var val2         = iter.FetchNextValue(c2);
                var val3         = iter.FetchNextValue(c3);
                var assertResult = factory.FetchDecisionFunction(decisionType).Invoke(new[] { val1, val2, val3 });
                var testResult   = new TestRunResult();
                if (assertResult)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg, val2, output.Variable, val1, val3);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                if (dataObject.IsDebugMode())
                {
                    var msg = testResult.Message;
                    if (testResult.RunTestResult == RunResult.TestPassed)
                    {
                        msg = Messages.Test_PassedResult;
                    }

                    var hasError = testResult.RunTestResult == RunResult.TestFailed;

                    var       debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(msg, hasError);
                    DebugItem itemToAdd = new DebugItem();
                    itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());

                    if (debugState.AssertResultList != null)
                    {
                        bool addItem = debugState.AssertResultList.Select(debugItem => debugItem.ResultsList.Where(debugItemResult => debugItemResult.Value == Messages.Test_PassedResult)).All(debugItemResults => !debugItemResults.Any());

                        if (addItem)
                        {
                            debugState.AssertResultList.Add(itemToAdd);
                        }
                    }
                }
                output.Result = testResult;
                ret.Add(testResult);
            }
            return(ret);
        }
Example #11
0
        private IEnumerable <TestRunResult> GetTestRunResults(IDSFDataObject dataObject, IServiceTestOutput output, Dev2DecisionFactory factory)
        {
            var expressionType     = output.AssertOp ?? string.Empty;
            IFindRecsetOptions opt = FindRecsetOptions.FindMatch(expressionType);
            var decisionType       = DecisionDisplayHelper.GetValue(expressionType);

            if (decisionType == enDecisionType.IsError)
            {
                var hasErrors  = dataObject.Environment.AllErrors.Count > 0;
                var testResult = new TestRunResult();
                if (hasErrors)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                return(new[] { testResult });
            }
            if (decisionType == enDecisionType.IsNotError)
            {
                var noErrors   = dataObject.Environment.AllErrors.Count == 0;
                var testResult = new TestRunResult();
                if (noErrors)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                return(new[] { testResult });
            }
            var value = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.Value)
            };
            var from = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.From)
            };
            var to = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.To)
            };

            IList <TestRunResult> ret = new List <TestRunResult>();
            var iter     = new WarewolfListIterator();
            var variable = DataListUtil.AddBracketsToValueIfNotExist(output.Variable);
            var cols1    = dataObject.Environment.EvalAsList(variable, 0);
            var c1       = new WarewolfAtomIterator(cols1);
            var c2       = new WarewolfAtomIterator(value);
            var c3       = new WarewolfAtomIterator(to);

            if (opt.ArgumentCount > 2)
            {
                c2 = new WarewolfAtomIterator(from);
            }
            iter.AddVariableToIterateOn(c1);
            iter.AddVariableToIterateOn(c2);
            iter.AddVariableToIterateOn(c3);
            while (iter.HasMoreData())
            {
                var val1         = iter.FetchNextValue(c1);
                var val2         = iter.FetchNextValue(c2);
                var val3         = iter.FetchNextValue(c3);
                var assertResult = factory.FetchDecisionFunction(decisionType).Invoke(new[] { val1, val2, val3 });
                var testResult   = new TestRunResult();
                if (assertResult)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg, val2, variable, val1, val3);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                output.Result = testResult;
                ret.Add(testResult);
            }
            return(ret);
        }