Ejemplo n.º 1
0
 IEnumerable<string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo,int update)
 {
     WarewolfIterator iterator = new WarewolfIterator(env.Eval(sharepointSearchTo.ValueToMatch,update));
     while (iterator.HasMoreData())
     {
         var fieldType = sharepointFieldTo.GetFieldType();
         yield return string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef><Value Type=\"{2}\">{3}</Value>{4}", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName, fieldType, CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type), SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType));
     }
 }
Ejemplo n.º 2
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;
        }
 public void SharepointSearchTo_SearchCriteria_SetValue_FiresNotifyPropertyChanged()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo();
     const string searchCriteria = "MyValue";
     //------------Execute Test---------------------------
     // ReSharper disable ImplicitlyCapturedClosure
     var notifyPropertyChanged = TestUtils.PropertyChangedTester(searchTo, () => searchTo.ValueToMatch, () => searchTo.ValueToMatch = searchCriteria);
     // ReSharper restore ImplicitlyCapturedClosure
     //------------Assert Results-------------------------
     Assert.AreEqual(searchCriteria, searchTo.ValueToMatch);
     Assert.IsTrue(notifyPropertyChanged);
 }
        public void SharepointSearchTo_Constructor_Default_SetsProperties()
        {
            //------------Setup for test--------------------------
            //------------Execute Test---------------------------
            var searchTo = new SharepointSearchTo();
            //------------Assert Results-------------------------
            Assert.IsNotNull(searchTo);
            Assert.AreEqual("Field Name", searchTo.FieldName);
            Assert.AreEqual("", searchTo.ValueToMatch);
            Assert.AreEqual("Equal", searchTo.SearchType);
            Assert.AreEqual(0, searchTo.IndexNumber);
            Assert.IsFalse(searchTo.Inserted);
            Assert.IsFalse(searchTo.IsSearchCriteriaEnabled);

        }
 public void SharepointSearchTo_ParameterConstructor_SetsProperties()
 {
     //------------Setup for test--------------------------
     const string searchCriteria = "Bob";
     const string searchType = ">";
     const int indexNum = 3;
     const string fieldName = "Title";
     //------------Execute Test---------------------------
     var searchTo = new SharepointSearchTo(fieldName,searchType, searchCriteria, indexNum);
     //------------Assert Results-------------------------
     Assert.IsNotNull(searchTo);
     Assert.AreEqual(fieldName, searchTo.FieldName);
     Assert.AreEqual(searchCriteria, searchTo.ValueToMatch);
     Assert.AreEqual(searchType, searchTo.SearchType);
     Assert.AreEqual(indexNum, searchTo.IndexNumber);
     Assert.IsFalse(searchTo.Inserted);
     Assert.IsFalse(searchTo.IsSearchCriteriaEnabled);
 }
 IEnumerable<string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo,int update)
 {
     var warewolfEvalResult = env.Eval(sharepointSearchTo.ValueToMatch, update);
     var fieldType = sharepointFieldTo.GetFieldType();
     if (sharepointSearchTo.SearchType == "In")
     {
         var startSearchTerm = string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef>", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName);
        
         startSearchTerm+="<Values>";
         if(warewolfEvalResult.IsWarewolfAtomListresult)
         {
             var listResult = warewolfEvalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult;
             if (listResult != null)
             {
                 foreach(var warewolfAtom in listResult.Item)
                 {
                     var valueString = warewolfAtom.ToString();
                     if (valueString.Contains(","))
                     {
                         var listOfValues = valueString.Split(',');
                         startSearchTerm = listOfValues.Select(listOfValue => CastWarewolfValueToCorrectType(listOfValue, sharepointFieldTo.Type)).Aggregate(startSearchTerm, (current, value) => current + string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value));
                     }
                     else
                     {
                         var value = CastWarewolfValueToCorrectType(valueString, sharepointFieldTo.Type);
                         startSearchTerm += string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value);
                     }
                 }
             }
         }else
         {
             var scalarResult = warewolfEvalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult;
             if(scalarResult!=null)
             {
                 var valueString = scalarResult.Item.ToString();
                 if (valueString.Contains(","))
                 {
                     var listOfValues = valueString.Split(',');
                     startSearchTerm = listOfValues.Select(listOfValue => CastWarewolfValueToCorrectType(listOfValue, sharepointFieldTo.Type)).Aggregate(startSearchTerm, (current, value) => current + string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value));
                 }
                 else
                 {
                     var value = CastWarewolfValueToCorrectType(valueString, sharepointFieldTo.Type);
                     startSearchTerm += string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value);
                 }
             }
         }
         startSearchTerm += "</Values>";
         startSearchTerm += SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType);
         yield return startSearchTerm;
     }
     else
     {
         
         WarewolfIterator iterator = new WarewolfIterator(warewolfEvalResult);
         while (iterator.HasMoreData())
         {
             yield return string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef><Value Type=\"{2}\">{3}</Value>{4}", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName, fieldType, CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type), SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType));
         }
     }
 }
 public void SharepointSearchTo_IndexNum_SetValue_FiresNotifyPropertyChanged()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo();
     const int indexNum = 5;
     //------------Execute Test---------------------------
     var notifyPropertyChanged = TestUtils.PropertyChangedTester(searchTo, () => searchTo.IndexNumber, () => searchTo.IndexNumber = indexNum);
     //------------Assert Results-------------------------
     Assert.AreEqual(indexNum, searchTo.IndexNumber);
     Assert.IsTrue(notifyPropertyChanged);
 }
 static void VerifyCorrectRulesForEachField(SharepointSearchTo searchTo, string fieldName,List<Type> ruleTypes)
 {
     //------------Execute Test---------------------------
     var rulesSet = searchTo.GetRuleSet(fieldName, "");
     //------------Assert Results-------------------------
     Assert.IsNotNull(rulesSet);
     Assert.AreEqual(ruleTypes.Count,rulesSet.Rules.Count);
     var returnedRuleTypes = rulesSet.Rules.Select(rule => rule.GetType());
     CollectionAssert.AreEqual(ruleTypes,returnedRuleTypes.ToList());
 }
 public void SharepointSearchTo_GetRuleSet_OnFieldNameNoValue_ReturnTwoRules()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo {  FieldName = string.Empty };
     VerifyCorrectRulesForEachField(searchTo, "FieldName",new List<Type> { typeof(IsStringEmptyRule) });
 }
 public void SharepointSearchTo_GetRuleSet_OnValueToMatchWithValue_ReturnOneRules()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo { SearchType = "Equals", ValueToMatch = "Bob" };
     VerifyCorrectRulesForEachField(searchTo, "ValueToMatch", new List<Type> { typeof(IsValidExpressionRule) });
 }
 public void SharepointSearchTo_GetRuleSet_OnValueToMatchNoValue_ReturnTwoRules()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo { SearchType = "Equals", ValueToMatch = string.Empty };
     VerifyCorrectRulesForEachField(searchTo, "ValueToMatch", new List<Type> { typeof(IsStringEmptyRule), typeof(IsValidExpressionRule) });
 }
 public void SharepointSearchTo_CanRemove_FieldNameEmptyWithData_ReturnFalse()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo { FieldName = "Contains"};
     //------------Execute Test---------------------------
     var canRemove = searchTo.CanRemove();
     //------------Assert Results-------------------------
     Assert.IsFalse(canRemove);
 }
 public void SharepointSearchTo_CanRemove_FieldNameEmpty_ReturnTrue()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo { FieldName = string.Empty };
     //------------Execute Test---------------------------
     var canRemove = searchTo.CanRemove();
     //------------Assert Results-------------------------
     Assert.IsTrue(canRemove);
 }
 public void SharepointSearchTo_CanAdd_SearchTypeWithData_ReturnTrue()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo { SearchType = "Contains", FieldName = "Title"};
     //------------Execute Test---------------------------
     var canAdd = searchTo.CanAdd();
     //------------Assert Results-------------------------
     Assert.IsTrue(canAdd);
 }
 public void SharepointSearchTo_CanAdd_FieldNameEmpty_ReturnFalse()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo { SearchType = "Equal",FieldName = string.Empty};
     //------------Execute Test---------------------------
     var canAdd = searchTo.CanAdd();
     //------------Assert Results-------------------------
     Assert.IsFalse(canAdd);
 }
 public void SharepointSearchTo_IsSearchCriteriaEnabled_SetValue_FiresNotifyPropertyChanged()
 {
     //------------Setup for test--------------------------
     var searchTo = new SharepointSearchTo();
     const bool isSearchCriteriaEnabled = true;
     //------------Execute Test---------------------------
     var notifyPropertyChanged = TestUtils.PropertyChangedTester(searchTo, () => searchTo.IsSearchCriteriaEnabled, () => searchTo.IsSearchCriteriaEnabled = isSearchCriteriaEnabled);
     //------------Assert Results-------------------------
     Assert.AreEqual(isSearchCriteriaEnabled, searchTo.IsSearchCriteriaEnabled);
     Assert.IsTrue(notifyPropertyChanged);
 }