public void DebugItemWarewolfAtomListResult_IsListOldValue_GetDebugItemResult()
        {
            //---------------Set up test pack-------------------
            var env = new Mock <IExecutionEnvironment>();

            env.Setup(environment => environment.EvalToExpression(It.IsAny <string>(), It.IsAny <int>())).Returns("[[scalar]]");
            var warewolfAtomResult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.NewDataString("{\"PolicyNo\":\"A0003\",\"DateId\":32,\"SomeVal\":\"Bob\"}"));

            env.Setup(environment => environment.Eval(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(warewolfAtomResult);
            var atomList = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.NewDataString("Home"));
            var newWarewolfAtomListresult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(atomList) as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;

            Assert.IsNotNull(newWarewolfAtomListresult);
            newWarewolfAtomListresult.Item.AddSomething(DataStorage.WarewolfAtom.NewDataString("KingDom Of The Zulu"));
            var debugEvalResult = new DebugItemWarewolfAtomListResult(newWarewolfAtomListresult, newWarewolfAtomListresult, "newValue(1)", "Variable", "", "Some right label text", "");

            //---------------Assert Precondition----------------
            Assert.IsNotNull(debugEvalResult);
            //---------------Execute Test ----------------------
            Assert.AreEqual("", debugEvalResult.LabelText);
            var debugItemResults = debugEvalResult.GetDebugItemResult();

            //---------------Test Result -----------------------
            Assert.AreEqual(1, debugItemResults.Count);
            Assert.AreEqual("KingDom Of The Zulu", debugItemResults[0].Value);
        }
Beispiel #2
0
        public void WarewolfIterator_Construct_GivenList()
        {
            var item1 = DataStorage.WarewolfAtom.NewDataString("some string");
            var item2 = DataStorage.WarewolfAtom.NewFloat(3.2);
            var item3 = DataStorage.WarewolfAtom.NewInt(1234);
            var item4 = DataStorage.WarewolfAtom.NewPositionedValue(new Tuple <int, DataStorage.WarewolfAtom>(3, DataStorage.WarewolfAtom.NewDataString("positioned value")));

            var values = new List <DataStorage.WarewolfAtom>
            {
                item1,
                item2,
                item3,
                item4,
            };

            var warewolfAtomList       = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.NewDataString("some default value"), values);
            var warewolfAtomListResult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(warewolfAtomList);

            var iterator = new WarewolfIterator(warewolfAtomListResult);

            Assert.AreEqual("\r\n", iterator.NewLineFormat);

            Assert.AreEqual(4, iterator.GetLength());

            Assert.IsTrue(iterator.HasMoreData());
            Assert.AreEqual("some string", iterator.GetNextValue());
            Assert.IsTrue(iterator.HasMoreData());
            Assert.AreEqual("3.2", iterator.GetNextValue());
            Assert.IsTrue(iterator.HasMoreData());
            Assert.AreEqual("1234", iterator.GetNextValue());
            Assert.IsTrue(iterator.HasMoreData());
            Assert.AreEqual("positioned value", iterator.GetNextValue());
            Assert.IsFalse(iterator.HasMoreData());
        }
 public WarewolfDataEvaluationCommon.WarewolfEvalResult EvalForJson(string exp)
 {
     if (string.IsNullOrEmpty(exp))
     {
         return(WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomResult(DataASTMutable.WarewolfAtom.Nothing));
     }
     try
     {
         return(PublicFunctions.EvalEnvExpression(exp, 0, _env));
     }
     catch (IndexOutOfRangeException)
     {
         throw;
     }
     catch (Exception e)
     {
         if (e is IndexOutOfRangeException)
         {
             throw;
         }
         if (IsRecordsetIdentifier(exp))
         {
             var res = new WarewolfAtomList <DataASTMutable.WarewolfAtom>(DataASTMutable.WarewolfAtom.Nothing);
             res.AddNothing();
             return(WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomListresult(res));
         }
         return(WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomResult(DataASTMutable.WarewolfAtom.Nothing));
     }
 }
Beispiel #4
0
        public void WarewolfIterator_Construct_GivenRecordset()
        {
            var expectedResult = "some string0,3.2,1234,positioned value0,some string1,4.2,1235,positioned value1,some string2,5.2,1236,positioned value2,some string3,6.2,1237,positioned value3";

            IEnumerable <Tuple <string, WarewolfAtomList <DataStorage.WarewolfAtom> > > generateElements()
            {
                for (int i = 0; i < 4; i++)
                {
                    var warewolfAtomList = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.NewDataString("some default value"), new List <DataStorage.WarewolfAtom>
                    {
                        DataStorage.WarewolfAtom.NewDataString("some string" + i),
                        DataStorage.WarewolfAtom.NewFloat(3.2 + i),
                        DataStorage.WarewolfAtom.NewInt(1234 + i),
                        DataStorage.WarewolfAtom.NewPositionedValue(new Tuple <int, DataStorage.WarewolfAtom>(3 + i, DataStorage.WarewolfAtom.NewDataString("positioned value" + i))),
                    });
                    yield return(new Tuple <string, WarewolfAtomList <DataStorage.WarewolfAtom> >("col" + i, warewolfAtomList));
                }
            }

            var fSharpMap = new Microsoft.FSharp.Collections.FSharpMap <string, WarewolfAtomList <DataStorage.WarewolfAtom> >(generateElements());

            var warewolfRecordset       = new DataStorage.WarewolfRecordset(fSharpMap, DataStorage.WarewolfAttribute.Sorted, 0, 0);
            var warewolfRecordsetResult = CommonFunctions.WarewolfEvalResult.NewWarewolfRecordSetResult(warewolfRecordset);

            var iterator = new WarewolfIterator(warewolfRecordsetResult);

            Assert.AreEqual("\r\n", iterator.NewLineFormat);

            Assert.AreEqual(1, iterator.GetLength());

            Assert.IsTrue(iterator.HasMoreData());
            Assert.AreEqual(expectedResult, iterator.GetNextValue());
            Assert.IsFalse(iterator.HasMoreData());
        }
Beispiel #5
0
        public CommonFunctions.WarewolfEvalResult EvalForJson(string exp, bool shouldEscape)
        {
            if (string.IsNullOrEmpty(exp))
            {
                return(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.Nothing));
            }

            try
            {
                return(PublicFunctions.EvalEnvExpression(exp, 0, shouldEscape, _env));
            }
            catch (IndexOutOfRangeException)
            {
                throw;
            }
            catch (Exception)
            {
                if (!IsRecordsetIdentifier(exp))
                {
                    return(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.Nothing));
                }

                var res = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.Nothing);
                res.AddNothing();
                return(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(res));
            }
        }
Beispiel #6
0
        object GetEvalResult(CommonFunctions.WarewolfEvalResult evalResult, int i)
        {
            if (evalResult.IsWarewolfAtomListresult)
            {
                WarewolfAtomList <DataStorage.WarewolfAtom> lst = ((CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult)evalResult).Item;
                if (i > lst.Count)
                {
                    return(null);
                }
                return(CommonFunctions.atomToJsonCompatibleObject(lst[i]));
            }
            if (evalResult.IsWarewolfAtomResult)
            {
                if (i == 0)
                {
                    return(CommonFunctions.evalResultToJsonCompatibleObject(evalResult));
                }
                return(null);
            }
            if (evalResult.IsWarewolfRecordSetResult)
            {
                DataStorage.WarewolfRecordset recset = ((CommonFunctions.WarewolfEvalResult.WarewolfRecordSetResult)EvalResult).Item;

                KeyValuePair <string, WarewolfAtomList <DataStorage.WarewolfAtom> >[] data = recset.Data.ToArray();
                var jObjects = new List <JObject>();
                for (int j = 0; j < recset.Count; j++)
                {
                    var a = new JObject();
                    foreach (KeyValuePair <string, WarewolfAtomList <DataStorage.WarewolfAtom> > pair in data)
                    {
                        if (pair.Key != FsInteropFunctions.PositionColumn)
                        {
                            try
                            {
                                a.Add(new JProperty(pair.Key, CommonFunctions.atomToJsonCompatibleObject(pair.Value[j])));
                            }
                            catch (Exception)
                            {
                                a.Add(new JProperty(pair.Key, null));
                            }
                        }
                    }
                    jObjects.Add(a);
                }
                return(jObjects);
            }
            throw new Exception(ErrorResource.InvalidResultTypeFromWarewolfStorage);
        }
Beispiel #7
0
        object GetEvalResult(WarewolfDataEvaluationCommon.WarewolfEvalResult evalResult, int i)
        {
            if (evalResult.IsWarewolfAtomListresult)
            {
                WarewolfAtomList <DataASTMutable.WarewolfAtom> lst = ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult)evalResult).Item;
                if (i > lst.Count)
                {
                    return(null);
                }
                return(WarewolfDataEvaluationCommon.AtomToJsonCompatibleObject(lst[i]));
            }
            if (evalResult.IsWarewolfAtomResult)
            {
                if (i == 0)
                {
                    return(WarewolfDataEvaluationCommon.EvalResultToJsonCompatibleObject(evalResult));
                }
                return(null);
            }
            if (evalResult.IsWarewolfRecordSetResult)
            {
                DataASTMutable.WarewolfRecordset recset = ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfRecordSetResult)EvalResult).Item;

                KeyValuePair <string, WarewolfAtomList <DataASTMutable.WarewolfAtom> >[] data = recset.Data.ToArray();
                var jObjects = new List <JObject>();
                for (int j = 0; j < recset.Count; j++)
                {
                    var a = new JObject();
                    foreach (KeyValuePair <string, WarewolfAtomList <DataASTMutable.WarewolfAtom> > pair in data)
                    {
                        if (pair.Key != WarewolfDataEvaluationCommon.PositionColumn)
                        {
                            try
                            {
                                a.Add(new JProperty(pair.Key, WarewolfDataEvaluationCommon.AtomToJsonCompatibleObject(pair.Value[j])));
                            }
                            catch (Exception)
                            {
                                a.Add(new JProperty(pair.Key, null));
                            }
                        }
                    }
                    jObjects.Add(a);
                }
                return(jObjects);
            }
            throw new Exception("Invalid result type was encountered from warewolfstorage");
        }
        public void DebugItemWarewolfAtomListResult_GetDebugItemResult()
        {
            //---------------Set up test pack-------------------
            var env = new Mock <IExecutionEnvironment>();

            env.Setup(environment => environment.EvalToExpression(It.IsAny <string>(), It.IsAny <int>())).Returns("[[@scalar()]]");
            var warewolfAtomResult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.NewDataString("{\"PolicyNo\":\"A0003\",\"DateId\":32,\"SomeVal\":\"Bob\"}"));

            env.Setup(environment => environment.Eval(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(warewolfAtomResult);
            var atomList = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.NewDataString("Home"));
            var newWarewolfAtomListresult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(atomList) as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;
            var debugEvalResult           = new DebugItemWarewolfAtomListResult(newWarewolfAtomListresult, "newValue", "[[@home]]", "a", "b", "b", "");
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            var debugItemResults = debugEvalResult.GetDebugItemResult();
            //---------------Test Result -----------------------
            var value   = debugItemResults[0].Value;
            var operato = debugItemResults[0].Operator;

            Assert.AreEqual("newValue", value);
            Assert.AreEqual("", debugEvalResult.LabelText);
            Assert.AreEqual("=", operato);
        }
 void AssignWithFrameAndList(string assignValue, WarewolfAtomList<DataASTMutable.WarewolfAtom> item, bool shouldUseLast)
 {
    _env = PublicFunctions.EvalAssignFromList(assignValue, item,_env,shouldUseLast);
 }
Beispiel #10
0
        public void WfExecutionContainer_ExecuteNode_WhenSeverSettings_EnableDetailedLogging_IsTrue_ShouldRunLogExecuteException()
        {
            //--------------Arrange------------------------------
            var dataObjectMock           = new Mock <IDSFDataObject>();
            var workSpaceMock            = new Mock <IWorkspace>();
            var esbChannelMock           = new Mock <IEsbChannel>();
            var executionEnvironmentMock = new Mock <IExecutionEnvironment>();
            var serviceAction            = new ServiceAction();
            var mockStateNotifier        = new Mock <IStateNotifier>();
            var mockExecutionManager     = new Mock <IExecutionManager>();
            var activityParserMock       = new Mock <IActivityParser>();
            var activityMock             = new Mock <IDev2Activity>();

            var dev2WorkflowSettings = new Mock <Dev2.Common.Interfaces.IDev2WorkflowSettings>();

            dev2WorkflowSettings.Setup(o => o.EnableDetailedLogging).Returns(true);
            dev2WorkflowSettings.Setup(o => o.ExecutionLogLevel).Returns(LogLevel.DEBUG.ToString);
            var atomList = new WarewolfAtomList <DataStorage.WarewolfAtom>(DataStorage.WarewolfAtom.Nothing);

            atomList.AddSomething(DataStorage.WarewolfAtom.NewDataString("Bob"));
            atomList.AddSomething(DataStorage.WarewolfAtom.NewDataString("Stub"));
            executionEnvironmentMock.Setup(environment => environment.Eval(It.IsAny <string>(), It.IsAny <int>())).Returns(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomListresult(atomList));
            executionEnvironmentMock.Setup(o => o.AddError(It.IsAny <string>())).Verifiable();

            dataObjectMock.SetupGet(o => o.Environment).Returns(executionEnvironmentMock.Object);
            dataObjectMock.SetupGet(o => o.Environment.AllErrors)
            .Returns(new HashSet <string> {
                "2nd false error from WfExecutionContainerTests"
            });
            dataObjectMock.SetupGet(o => o.Environment.Errors)
            .Returns(new HashSet <string> {
                "1st false error from WfExecutionContainerTests"
            });
            dataObjectMock.Setup(o => o.Environment.FetchErrors())
            .Returns("1st false error from WfExecutionContainerTests, 2nd false error from WfExecutionContainerTests");

            var falseException = new Exception("1st false error from WfExecutionContainerTests, 2nd false error from WfExecutionContainerTests");

            dataObjectMock.Setup(o => o.StopExecution).Returns(false);
            dataObjectMock.Setup(o => o.ExecutionException).Returns(falseException);
            dataObjectMock.Setup(o => o.Settings).Returns(dev2WorkflowSettings.Object);
            dataObjectMock.Setup(o => o.StateNotifier).Returns(mockStateNotifier.Object);

            mockStateNotifier.Setup(o => o.LogActivityExecuteState(It.IsAny <IDev2Activity>())).Verifiable();
            mockStateNotifier.Setup(o => o.LogExecuteException(It.IsAny <Exception>(), It.IsAny <IDev2Activity>())).Verifiable();

            var logManagerMock = new Mock <IStateNotifierFactory>();

            logManagerMock.Setup(o => o.New(It.IsAny <IDSFDataObject>())).Returns(mockStateNotifier.Object);

            activityMock.Setup(o => o.Execute(dataObjectMock.Object, 0)).Throws(falseException);
            activityParserMock.Setup(o => o.Parse(It.IsAny <DynamicActivity>())).Returns(activityMock.Object);

            CustomContainer.Register <IExecutionManager>(mockExecutionManager.Object);
            CustomContainer.Register <IStateNotifierFactory>(logManagerMock.Object);
            CustomContainer.Register <IActivityParser>(activityParserMock.Object);
            var wfExecutionContainer = new WfExecutionContainer(serviceAction, dataObjectMock.Object, workSpaceMock.Object, esbChannelMock.Object);

            //--------------Act----------------------------------
            wfExecutionContainer.Eval(FlowchartProcess, dataObjectMock.Object, 0);

            //--------------Assert-------------------------------
            Assert.IsNotNull(dataObjectMock.Object.ExecutionException);
            mockStateNotifier.Verify(o => o.LogExecuteException(falseException, activityMock.Object), Times.Once);
            mockStateNotifier.Verify(o => o.LogExecuteCompleteState(It.IsAny <IDev2Activity>()), Times.Never);
            mockStateNotifier.Verify(o => o.Dispose(), Times.Once);
            mockExecutionManager.Verify(o => o.CompleteExecution(), Times.Once);
        }
 // ReSharper disable once ParameterTypeCanBeEnumerable.Local
 void AssignWithFrameAndList(string assignValue, WarewolfAtomList <DataASTMutable.WarewolfAtom> item, bool shouldUseLast, int update)
 {
     _env = PublicFunctions.EvalAssignFromList(assignValue, item, _env, update, shouldUseLast);
 }
 public WarewolfDataEvaluationCommon.WarewolfEvalResult EvalForJson(string exp)
 {
     if (string.IsNullOrEmpty(exp))
     {
         return WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomResult(DataASTMutable.WarewolfAtom.Nothing);
     }
     try
     {
         return PublicFunctions.EvalEnvExpression(exp, 0,_env);
     }
     catch (IndexOutOfRangeException)
     {
         throw;
     }
     catch (Exception e)
     {
         if (e is IndexOutOfRangeException) throw;
         if(IsRecordsetIdentifier(exp))
         {
            var res =  new WarewolfAtomList<DataASTMutable.WarewolfAtom>(DataASTMutable.WarewolfAtom.Nothing);
             res.AddNothing();
             return WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomListresult(res);
         }
             return WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomResult(DataASTMutable.WarewolfAtom.Nothing);
     }
 }