示例#1
0
        public void TimezoneDstTest(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, string fieldCategory, string timezone, int timeOffset, Func <string> fieldNameProvider)
        {
            var request    = SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter(fieldNameProvider(), OperatorType.Eq, timezone, AltTestDateTime.AddHours(timeOffset).ToString(SearchConstants.SearchApiFullDateTemplate));
            var expectedId = RecordsCreator.Data[$"{resource} Alt"].Id;

            PerformHappyPathTest(resource, request, (int)expectedId);
        }
        private object GetFieldValueByFieldType(TestCoreFramework.Enums.FieldType fieldType, ResourceId resource, string fieldCategory)
        {
            if (FieldTypeToTest.Contains(fieldType))
            {
                switch (fieldType)
                {
                case TestCoreFramework.Enums.FieldType.Mail:
                    return($"{resource}.{fieldCategory}@mail.com");

                case TestCoreFramework.Enums.FieldType.MultiLinesText:
                    return($"{resource} MultiLinesText {fieldCategory}");

                case TestCoreFramework.Enums.FieldType.SingleLineText:
                    return($"{resource} SingleLineText {fieldCategory}");

                case TestCoreFramework.Enums.FieldType.Telephone:
                    return($"{ResourceToNumString(resource)}-{FieldCategoryToNumString(fieldCategory)}");

                case TestCoreFramework.Enums.FieldType.Url:
                    return($"http://{resource}.{fieldCategory}.com");

                case TestCoreFramework.Enums.FieldType.File:
                    return(null);
                }


                return($"{resource} {fieldType}");
            }

            return(SearchConstants.FieldTypeToFieldValueMap[fieldType](false));
        }
        public void SuccessfulSearch_AreaAllOnly_SplitModeNOT(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, OperatorType op, string fieldCategory)
        {
            var value = GetFieldValueByFieldType(fieldType, resource, fieldCategory).ToString();

            value = SearchValueTransformationsByOperator[op](value);
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).FreewordFilter(op, null, "NOT", "ALL", value);

            PerformSuccessfulInvertedSearchTest(resource, request);
        }
        public void SuccessfulSearch_TextOnly_SplitModeOR(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, OperatorType op, string fieldCategory)
        {
            var value = GetFieldValueByFieldType(fieldType, resource, fieldCategory).ToString();

            value = SearchValueTransformationsByOperator[op](value) + " SomeRandomString";
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).FreewordFilter(op, null, "OR", "TEXT", value);

            PerformSuccessfulSearchTest(resource, request);
        }
示例#5
0
        public static PrivateData <int> GetBulkUpdate(int numbRecords, int numRecordsEachCase, HrbcRecordCreator recordsCreator, string fieldValue, TestCoreFramework.Enums.FieldType type, HrbcFieldCreator fieldCreator)
        {
            return(new PrivateData <int>(
                       (session, test) =>
            {
                return Task.Run(() =>
                {
                    foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
                    {
                        var bulkManager = new BulkUpdateManager();

                        for (var i = 0; i < numbRecords - numRecordsEachCase; i++)
                        {
                            var recordId = recordsCreator.Data[$"{resource}{i}"].Id;
                            var response = bulkManager.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(resource, new List <ulong> {
                                recordId
                            }, i, fieldValue, type, fieldCreator), System.Net.Http.HttpMethod.Post);
                            PrAssume.That(response, PrIs.SuccessfulResponse());

                            if (GetBulkUpdateQueueStatus(response.Result.Id.ToString()))
                            {
                                continue;
                            }
                        }
                    }
                    return 0;
                });
            },
                       (session, test, res) => Task.Run(() =>
            {
            })));
        }
示例#6
0
        private static BulkUpdateProperties GetBulkUpdateContent(ResourceId resource, List <ulong> ids, int index, string testDateTime, TestCoreFramework.Enums.FieldType type, HrbcFieldCreator fieldCreator)
        {
            Func <ResourceId, KeyValuePair <object, FieldPropertyCollection>, KeyValuePair <string, FieldContent> > userFieldDataGenerator = (resourceId, x)
                                                                                                                                             => new KeyValuePair <string, FieldContent>(x.Value.Name, new FieldContent {
                Content = testDateTime
            });
            var fields = fieldCreator.Data.Where(x => x.Value.Field.Resource == resource)
                         .Select(x => userFieldDataGenerator(resource, x))
                         .Concat(new List <KeyValuePair <string, FieldContent> > {
                new KeyValuePair <string, FieldContent>(SearchConstants.FieldTypeToApplicationFieldNameMap[type], new FieldContent {
                    Content = testDateTime
                })
            })
                         .Concat(SearchConstants.SystemFieldsValues[resource].Where(x => type == x.Key).Select(field => new KeyValuePair <string, FieldContent>(field.Value, new FieldContent {
                Content = testDateTime
            })))
                         .ToDictionary(pair => pair.Key, pair => pair.Value);
            var bulkUpdate = new BulkUpdateProperties();

            bulkUpdate.Create                       = new Create();
            bulkUpdate.Create.Resource              = resource.ToString();
            bulkUpdate.Create.Tag                   = resource.ToString();
            bulkUpdate.Create.Records               = new Records();
            bulkUpdate.Create.Records.Ids           = ids;
            bulkUpdate.Create.Records.PhpSearch     = string.Empty;
            bulkUpdate.Create.Fields                = fields;
            bulkUpdate.Create.CheckPhasePermissions = true;
            return(bulkUpdate);
        }
示例#7
0
 public void HappyPathTest_ApplicationFields(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, SearchFilterType searchType, string caseDescription, Func <SearchRequest> requestProvider)
 {
     PerformHappyPathTest(resource, requestProvider());
 }
示例#8
0
 private object GetFieldValueByFieldType(TestCoreFramework.Enums.FieldType fieldType, bool isAlt)
 {
     return(SearchConstants.FieldTypeToFieldValueMap[fieldType](isAlt));
 }
示例#9
0
 private static Dictionary <string, Func <SearchRequest> > PrepareNumInCases(ResourceId resource, Func <string> fullFieldName, object testValue, object altTestValue, TestCoreFramework.Enums.FieldType fieldType)
 {
     if (fieldType == TestCoreFramework.Enums.FieldType.OptionCheckbox)
     {
         var range = (testValue as string[]);
         return(new Dictionary <string, Func <SearchRequest> >
         {
             [$"1:1 match {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range),
             ["Search is wider"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range.Append("42")),
             ["Search is narrower"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range.Skip(1)),
             ["Search is partially matching"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range.Skip(1).Append("42"))
         });
     }
     else
     {
         return(new Dictionary <string, Func <SearchRequest> >
         {
             [$"Value inside range {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), new[] { 0, testValue, altTestValue, 100010 })
         });
     }
 }
示例#10
0
        public static Dictionary <string, Func <SearchRequest> > PrepareTestCases(SearchFilterType searchType, ResourceId resource, Func <string> fieldName, TestCoreFramework.Enums.FieldType fieldType)
        {
            var testValue = SearchConstants.FieldTypeToFieldValueMap[fieldType](false);
            var altValue  = SearchConstants.FieldTypeToFieldValueMap[fieldType](true);

            Func <string> fullFieldName = () => $"{resource}.{fieldName()}";

            switch (searchType)
            {
            case SearchFilterType.NumIn:
                return(PrepareNumInCases(resource, fullFieldName, testValue, altValue, fieldType));

            case SearchFilterType.NumMinMax:
                return(PrepareNumMinMaxCases(resource, fullFieldName, testValue, altValue, fieldType));

            case SearchFilterType.NumAll:
                return(PrepareNumAllCases(resource, fullFieldName, testValue));

            case SearchFilterType.NumOperator:
                return(PrepareNumCases(resource, fullFieldName, testValue, altValue));

            case SearchFilterType.Date:
                return(PrepareDateCases(resource, fullFieldName, Convert.ToDateTime(testValue), Convert.ToDateTime(altValue)));

            case SearchFilterType.DateIn:
                return(PrepareDateInCases(resource, fullFieldName, Convert.ToDateTime(testValue), Convert.ToDateTime(altValue)));

            case SearchFilterType.DateMinMax:
                return(PrepareDateMinMaxCases(resource, fullFieldName, Convert.ToDateTime(testValue)));

            case SearchFilterType.Text:
                return(PrepareTextCases(resource, fullFieldName, testValue.ToString()));

            default:
                return(new Dictionary <string, Func <SearchRequest> >());
            }
        }
示例#11
0
 private static Dictionary <string, Func <SearchRequest> > PrepareNumMinMaxCases(ResourceId resource, Func <string> fullFieldName, object testValue, object altTestValue, TestCoreFramework.Enums.FieldType fieldType)
 {
     if (fieldType == TestCoreFramework.Enums.FieldType.OptionCheckbox)
     {
         var range = (testValue as string[]).Select(Convert.ToDouble);
         return(new Dictionary <string, Func <SearchRequest> >
         {
             [$"Min equals first item, max -- last {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumMinMaxFilter(fullFieldName(), range.First(), range.Last())
         });
     }
     else
     {
         return(new Dictionary <string, Func <SearchRequest> >
         {
             [$"Strictly within range {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumMinMaxFilter(fullFieldName(), ((double)testValue) - 1, ((double)testValue) + 1),
             ["Test value equals min"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumMinMaxFilter(fullFieldName(), ((double)testValue), ((double)testValue) + 1),
             ["Test value equals max"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumMinMaxFilter(fullFieldName(), ((double)testValue) - 1, ((double)testValue)),
             ["Test value equals max and min"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumMinMaxFilter(fullFieldName(), ((double)testValue), ((double)testValue))
         });
     }
 }
        public void ValueSearchOnEmptyFields_BoolNotTest(ResourceId masterResource, ResourceId referencedResource, TestCoreFramework.Enums.FieldType referencedFieldType, SearchFilterType searchType, string caseDescription, Func <SearchRequest> searchRequestProvider)
        {
            var requesnt = SearchRequestComposer.GetBuilderWithRestrictions(masterResource).BooleanNotFilter(searchRequestProvider().Conditions.Filter);

            PerformSearchTest(masterResource, requesnt, CheckResultContainsExpectedRecord);
        }
 public void ValueSearchOnEmptyFieldsTest(ResourceId masterResource, ResourceId referencedResource, TestCoreFramework.Enums.FieldType referencedFieldType, SearchFilterType searchType, string caseDescription, Func <SearchRequest> searchRequestProvider)
 {
     PerformSearchTest(masterResource, searchRequestProvider(), CheckResultDoesNotContainExpectedRecord);
 }
示例#14
0
 public static FieldType ToFieldType(this TestCoreFramework.Enums.FieldType fType)
 {
     return((FieldType)((int)fType));
 }