Example #1
0
        public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            var env1 = env;

            Compound    = compound;
            Evaluations = new List <JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(env1, compound.SourceName));
            }
            else
            {
                Evaluations = FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0).IsRecordSetNameExpression ? new List <JsonMappingEvaluated> {
                    new JsonMappingEvaluated(env1, Compound.SourceName)
                } : ((LanguageAST.LanguageExpression.ComplexExpression)FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0))
                .Item
                .Where(x => !x.IsWarewolfAtomExpression)
                .Select(FsInteropFunctions.LanguageExpressionToString)
                .Select(x =>
                        new JsonMappingEvaluated(env1, x))
                .ToList();
            }
        }
 public void JsonMappingTo_CanAddRemove_HasDestinationName_CanRemoveFalse_CanAddTrue()
 {
     //------------Setup for test--------------------------
     var jsonMappingTo = new JsonMappingTo();
     jsonMappingTo.SourceName = "";
     jsonMappingTo.DestinationName = "val";
     //-------------Assert-----------------------------------
     Assert.IsFalse(jsonMappingTo.CanRemove());
     Assert.IsTrue(jsonMappingTo.CanAdd());
 }
Example #3
0
        public static IDev2TOFn CreateNewDTO(IDev2TOFn dto, int index = 0, bool inserted = false, string initializeWith = "")
        {
            IDev2TOFn toReturn = null;

            TypeSwitch.Do(dto,
                // ReSharper disable ImplicitlyCapturedClosure
                TypeSwitch.Case<ActivityDTO>(x => toReturn = new ActivityDTO(initializeWith, "", index, inserted)),
                // ReSharper restore ImplicitlyCapturedClosure
                TypeSwitch.Case<DataSplitDTO>(x =>
                {
                    var dataSplitDto = dto as DataSplitDTO;
                    if(dataSplitDto != null)
                    {
                        toReturn = new DataSplitDTO(initializeWith, dataSplitDto.SplitType, dataSplitDto.At, index, false, inserted);
                    }
                }),
                TypeSwitch.Case<DataMergeDTO>(x =>
                {
                    var dataMergeDto = dto as DataMergeDTO;
                    if(dataMergeDto != null)
                    {
                        toReturn = new DataMergeDTO(initializeWith, dataMergeDto.MergeType, dataMergeDto.At, index, dataMergeDto.Padding, dataMergeDto.Alignment, inserted);
                    }
                }),
                TypeSwitch.Case<CaseConvertTO>(x =>
                {
                    var caseConvertTO = dto as CaseConvertTO;
                    if(caseConvertTO != null)
                    {
                        toReturn = CaseConverterFactory.CreateCaseConverterTO(initializeWith, caseConvertTO.ConvertType, caseConvertTO.Result, index);
                    }
                }),
                TypeSwitch.Case<BaseConvertTO>(x =>
                {
                    var baseConvertTO = dto as BaseConvertTO;
                    if(baseConvertTO != null)
                    {
                        toReturn = new BaseConvertTO(initializeWith, baseConvertTO.FromType, baseConvertTO.ToType, baseConvertTO.ToExpression, index, inserted);
                    }
                }),
                // ReSharper disable ImplicitlyCapturedClosure
                TypeSwitch.Case<GatherSystemInformationTO>(x => toReturn =
                    new GatherSystemInformationTO(enTypeOfSystemInformationToGather.FullDateTime,
                        initializeWith, index, inserted)),
                TypeSwitch.Case<XPathDTO>(x => toReturn = new XPathDTO(initializeWith, "", index, inserted)),
                TypeSwitch.Case<FindRecordsTO>(() => toReturn = new FindRecordsTO("", "", index, inserted)),
                TypeSwitch.Case<JsonMappingTo>(() => toReturn = new JsonMappingTo(initializeWith, index, inserted)),
                TypeSwitch.Case<SharepointSearchTo>(() => toReturn = new SharepointSearchTo(initializeWith, "=", "", index, inserted)),
                TypeSwitch.Case<SharepointReadListTo>(() => toReturn = new SharepointReadListTo("", initializeWith, "","")),
                //REPLACE WITH SHAREPOINT DELETE ACTIVITY
                //TypeSwitch.Case<SharepointReadListTo>(() => toReturn = new SharepointReadListTo("", initializeWith, "")),
            TypeSwitch.Default(() => toReturn = null));

            return toReturn;
        }
Example #4
0
 public JsonMappingEvaluated(
     IExecutionEnvironment env,
     string sourceName)
 {
     _env = env;
     Simple = new JsonMappingTo
     {
         SourceName = sourceName,
         DestinationName = CalculateDestinationNameFromSourceName(sourceName)
     };
 }
Example #5
0
 public JsonMappingEvaluated(
     IExecutionEnvironment env,
     string sourceName)
 {
     _env   = env;
     Simple = new JsonMappingTo
     {
         SourceName      = sourceName,
         DestinationName = CalculateDestinationNameFromSourceName(sourceName)
     };
 }
 public void CreateJsonDesignerViewModel_CustomAction_WhenSourceNameChangedToScalar_UpdatesDestinationNameScalarName()
 {
     //------------Setup for test--------------------------
     var jsonMappingTo = new JsonMappingTo();
     var act = new DsfCreateJsonActivity { JsonMappings = new List<JsonMappingTo> { jsonMappingTo } };
     var vm = CreateViewModel(act);
     var mi = vm.ModelItemCollection[0];
     vm.CurrentModelItem = mi;
     //------------Execute Test---------------------------
     jsonMappingTo.SourceName = "[[var]]";
     //------------Assert Results-------------------------
     Assert.AreEqual("var",mi.GetProperty<string>("DestinationName"));
     Assert.AreEqual("var",jsonMappingTo.DestinationName);
 }
        public void JsonMappingTo_Clear()
        {
            //------------Setup for test--------------------------
            var jsonMappingTo = new JsonMappingTo();
            jsonMappingTo.SourceName = "bob";
            jsonMappingTo.DestinationName = "asd";



            //------------Execute Test---------------------------
            jsonMappingTo.ClearRow();
            //------------Assert Results-------------------------
            Assert.AreEqual("",jsonMappingTo.SourceName);
            Assert.AreEqual("", jsonMappingTo.DestinationName);
        }
        public void JsonMappingTo_Validate_ValidAndInvalidPassThrough()
        {
            //------------Setup for test--------------------------
            var jsonMappingTo = new JsonMappingTo();
            Assert.IsTrue(jsonMappingTo.GetRuleSet("SourceName", "").ValidateRules().Count == 0);
            jsonMappingTo.SourceName = "bob";
            Assert.IsTrue(jsonMappingTo.GetRuleSet("SourceName","").ValidateRules().Count==0);
            jsonMappingTo.SourceName = "[[rec()]],[[a]]";
         



            //------------Execute Test---------------------------
            Assert.IsTrue(jsonMappingTo.GetRuleSet("SourceName", "[[rec()]],[[a]]").ValidateRules().Count > 0);
            //------------Assert Results-------------------------
        }
Example #9
0
        public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            var env1 = env;

            Compound    = compound;
            Evaluations = new List <JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(env1, compound.SourceName));
            }
            else
            {
                if (FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0).IsRecordSetNameExpression)
                {
                    Evaluations = new List <JsonMappingEvaluated> {
                        new JsonMappingEvaluated(env1, Compound.SourceName)
                    };
                }
                else
                {
                    // we know this is a comma seperated list of expressions
                    Evaluations =
                        // ReSharper disable MaximumChainedReferences
                        ((LanguageAST.LanguageExpression.ComplexExpression)FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0))
                        .Item
                        .Where(x => !x.IsWarewolfAtomExpression)
                        .Select(FsInteropFunctions.LanguageExpressionToString)
                        .Select(x =>
                                new JsonMappingEvaluated(env1, x))
                        .ToList();
                }         // ReSharper restore MaximumChainedReferences
            }
        }
Example #10
0
        public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            _env = env;

            Compound = compound;
            Evaluations = new List<JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(_env, compound.SourceName));
            }
            else
            {
                if (WarewolfDataEvaluationCommon.ParseLanguageExpression(Compound.SourceName,0).IsRecordSetNameExpression)
                {
                    Evaluations = new List<JsonMappingEvaluated> { new JsonMappingEvaluated(_env, Compound.SourceName) };
                }
                else
                {
                    // we know this is a comma seperated list of expressions
                    Evaluations =
                        // ReSharper disable MaximumChainedReferences
                        ((LanguageAST.LanguageExpression.ComplexExpression)WarewolfDataEvaluationCommon.ParseLanguageExpression(Compound.SourceName,0))
                            .Item
                            .Where(x => !x.IsWarewolfAtomAtomExpression)
                            .Select(WarewolfDataEvaluationCommon.LanguageExpressionToString)
                            .Select(x =>
                                new JsonMappingEvaluated(_env, x))
                            .ToList();
                }         // ReSharper restore MaximumChainedReferences
            }
        }
 public void CreateJsonDesignerViewModel_CustomAction_WhenSourceNameChangedToVariableButDestinationAlreadyPopulated_DoesNotUpdatesDestinationName()
 {
     //------------Setup for test--------------------------
     var jsonMappingTo = new JsonMappingTo();
     var act = new DsfCreateJsonActivity { JsonMappings = new List<JsonMappingTo> { jsonMappingTo } };
     var vm = CreateViewModel(act);
     var mi = vm.ModelItemCollection[0];
     vm.CurrentModelItem = mi;
     jsonMappingTo.SourceName = "[[rec(*)]]";
     //------------Assert Preconditions-------------------
     Assert.AreEqual("rec", mi.GetProperty<string>("DestinationName"));
     Assert.AreEqual("rec", jsonMappingTo.DestinationName);
     //------------Execute Test---------------------------
     jsonMappingTo.SourceName = "[[a]]";
     //------------Assert Results-------------------------
     Assert.AreEqual("rec", mi.GetProperty<string>("DestinationName"));
     Assert.AreEqual("rec", jsonMappingTo.DestinationName);
 }
 public void CreateJsonDesignerViewModel_CustomAction_WhenSourceNameChangedToNonVariable_DoesNotUpdatesDestinationName()
 {
     //------------Setup for test--------------------------
     var jsonMappingTo = new JsonMappingTo();
     var act = new DsfCreateJsonActivity { JsonMappings = new List<JsonMappingTo> { jsonMappingTo } };
     var vm = CreateViewModel(act);
     var mi = vm.ModelItemCollection[0];
     vm.CurrentModelItem = mi;
     //------------Execute Test---------------------------
     jsonMappingTo.SourceName = "rec(*)";
     //------------Assert Results-------------------------
     Assert.IsTrue(string.IsNullOrEmpty(jsonMappingTo.DestinationName));
     Assert.IsTrue(string.IsNullOrEmpty(mi.GetProperty<string>("DestinationName")));
 }
 public void JsonMappingTo_Ctor()
 {
     //------------Setup for test--------------------------
     var jsonMappingTo = new JsonMappingTo("[[bob]]",1,false);
     Assert.AreEqual("bob", jsonMappingTo.DestinationName);
     Assert.AreEqual("[[bob]]", jsonMappingTo.SourceName);
     Assert.IsFalse(jsonMappingTo.CanRemove());
     Assert.AreEqual(1,jsonMappingTo.IndexNumber);
 }
        public void JsonMappingTo_SourceName_DoesNotSetsDestinationRecset()
        {
            //------------Setup for test--------------------------
            var jsonMappingTo = new JsonMappingTo();
            jsonMappingTo.DestinationName = "asdas";
            jsonMappingTo.SourceName = "[[bobby().tables]]";

            Assert.AreEqual("asdas", jsonMappingTo.DestinationName);
        }