Exemplo n.º 1
0
 private static string SearchConditionBySystemField(SearchFilterType searchFilterType, ResourceId resource)
 {
     if (searchFilterType.ToString().Contains("Date"))
     {
         return("P_UpdateDate");
     }
     else
     if (searchFilterType.ToString().Contains("Num"))
     {
         return("P_Id");
     }
     else
     {
         if (resource == ResourceId.Process)
         {
             return("P_PhaseMemo");
         }
         if (resource == ResourceId.Contract || resource == ResourceId.Recruiter)
         {
             return("P_Name");
         }
         if (resource == ResourceId.Resume)
         {
             return("P_Memo");
         }
         return(SearchConstants.SystemFieldsValues[resource][TestCoreFramework.Enums.FieldType.SingleLineText]);
     }
 }
Exemplo n.º 2
0
    private void ShowSelectedInput(SearchFilterType filterType)
    {
        switch (filterType)
        {
        case SearchFilterType.Text:
            ShowTextFilterInput();
            break;

        case SearchFilterType.Boolean:
            ShowBooleanFilterInput();
            break;

        case SearchFilterType.ValueRange:
            ShowValueRangeFilterInput();
            break;

        case SearchFilterType.Date:
            ShowDateRangeFilterInput();
            break;

        default:
            HideAllInput();

            RemoveSearchFilter();
            break;
        }
    }
Exemplo n.º 3
0
        private static SearchFilterType createRequestableFilter()
        {
            PropertyComplexValueFilterClauseType clause = new PropertyComplexValueFilterClauseType();

            clause.path = createItemPathType("requestable");
            clause.Item = true;

            SearchFilterType filter = new SearchFilterType();

            filter.Item            = clause;
            filter.ItemElementName = ItemChoiceType1.equal;
            return(filter);
        }
Exemplo n.º 4
0
        private static SearchFilterType createNameFilter(String name)
        {
            PropertyComplexValueFilterClauseType clause = new PropertyComplexValueFilterClauseType();

            clause.path = createItemPathType("name");
            clause.Item = name;

            SearchFilterType filter = new SearchFilterType();

            filter.Item            = clause;
            filter.ItemElementName = ItemChoiceType1.equal;
            return(filter);
        }
Exemplo n.º 5
0
    private void PopulateValueRangeFilter(SearchFilterType typeField,
                                          string field, string value, string val1, string val2, EventArgs e)
    {
        SearchType = typeField;
        FieldName  = field;
        FieldValue = value;
        Value1     = val1;
        Value2     = val2;

        DisplayValueRangeMessage(FieldName, Value1, Value2);

        // Propagate event to parent
        OnBubbleEvent(e);
    }
Exemplo n.º 6
0
        public void SearchTypeToFieldTypeTest(ResourceId resource, SearchFilterType filterType, FieldType fieldType, SearchRequest request, PrivateApiResponseCode expectedCode, string description)
        {
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            if (expectedCode == PrivateApiResponseCode.OK)
            {
                Assert.That(response, PrIs.SuccessfulResponse <SearchResponse>());
            }
            else
            {
                Assert.That(response, PrIs.ErrorResponse().And.ErrorCode((int)expectedCode).And.HttpCode(400));
            }
        }
Exemplo n.º 7
0
        private static ObjectType1[] listRequestableRoles(modelPortType modelPort)
        {
            SearchFilterType filter = createRequestableFilter();
            QueryType        query  = new QueryType();

            query.filter = filter;

            searchObjects         request  = new searchObjects(ROLE_TYPE, query, null);
            searchObjectsResponse response = modelPort.searchObjects(request);

            ObjectListType objectList = response.objectList;

            ObjectType1[] objects = objectList.@object;
            return(objects);
        }
        private bool TwoRecordsBeReturned(SearchFilterType searchFilterType)
        {
            switch (searchFilterType)
            {
            case SearchFilterType.NumMinMax:
            case SearchFilterType.Date:
            case SearchFilterType.DateIn:
            case SearchFilterType.DateMinMax:
            case SearchFilterType.FreeWord:
            case SearchFilterType.Subquery:
            case SearchFilterType.NumAll:
            case SearchFilterType.Text:
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 9
0
 private static PrivateApiResponseCode GetExpectedResponseCode(SearchFilterType searchType, OperatorType?operatorType)
 {
     if ((searchType == SearchFilterType.NumIn || searchType == SearchFilterType.NumAll) && !operatorType.HasValue)
     {
         return(PrivateApiResponseCode.OK);
     }
     if ((searchType == SearchFilterType.NumOperator || searchType == SearchFilterType.Date || searchType == SearchFilterType.DateIn) &&
         operatorType.HasValue &&
         (operatorType.Value == OperatorType.Eq || operatorType.Value == OperatorType.Neq))
     {
         return(PrivateApiResponseCode.OK);
     }
     if ((searchType == SearchFilterType.Text) && operatorType.HasValue && operatorType.Value == OperatorType.Eq)
     {
         return(PrivateApiResponseCode.OK);
     }
     return(PrivateApiResponseCode.NullParamterValue);
 }
Exemplo n.º 10
0
 public static string SystemFieldMapForMultiSearch(SearchFilterType searchFilterType, ResourceId resource)
 {
     if (searchFilterType.ToString().Contains("Date"))
     {
         return("P_UpdateDate");
     }
     else
     if (searchFilterType.ToString().Contains("Num"))
     {
         return("P_Id");
     }
     else
     {
         if (resource == ResourceId.Process)
         {
             return("P_PhaseMemo");
         }
         return(SearchConstants.SystemFieldsValues[resource][TestCoreFramework.Enums.FieldType.MultiLinesText]);
     }
 }
Exemplo n.º 11
0
        public void SearchWrongOperatorInBoolCondition(ResourceId resource, SearchFilterType filterType, OperatorType boolFilterType, SearchFilterType subFilterType, string fieldName)
        {
            var searchFilter = SearchHelpers.SearchFilters[subFilterType](resource, fieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond);

            SearchRequest request = null;

            if (filterType == SearchFilterType.BoolAndOr)
            {
                request = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, new[] { searchFilter });
            }
            else
            {
                request = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanNotFilter(searchFilter);
            }

            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
Exemplo n.º 12
0
        public void BulkDeleteWithSearchCondition(ResourceId resource, SearchFilterType filterType, string fieldName)
        {
            var expectedId    = RecordsCreatorForNumCond.Data[$"{resource}0"].Id;
            var searchRequest = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(OperatorType.Or, new List <SearchFilter> {
                SearchHelpers.SearchFilters[filterType](resource, fieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond)
            });
            var request = BulkHelpers.DefaultBulkDeleteParametersWithRecordIds(resource, new List <string>()) as Dictionary <string, object>;

            request["records"] = new Dictionary <string, object>
            {
                ["conditions"] = searchRequest.Conditions
            };
            var handler  = new DefaultManager();
            var response = handler.Send <BulkUpdateResponse>(BulkHelpers.BulkDeleteEndpoint, request.ToJson(), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssert.That(SearchHelpers.GetBulkUpdateQueueStatus(response.Result.Id.ToString(), BulkHelpers.WaitingTimeSecond, false), "Bulk delete is unsuccessful.");
            VerifyExistedId(resource, new List <string> {
                expectedId.ToString()
            });
        }
Exemplo n.º 13
0
        /// <summary>
        /// Search Youtube
        /// </summary>
        /// <param name="searchText"></param>
        /// <returns></returns>
        public async Task <IEnumerable <VideoWrapper> > SearchAsync(string searchText, string relatedTo = null, VideoSearchType videoSearchType = VideoSearchType.Videos, int pageNumber = 1, int pageSize = 20)
        {
            if (!string.IsNullOrEmpty(relatedTo))
            {
                searchText = $"(\"{searchText}\" | {string.Join("\"{0}\"|", relatedTo.Split(','))})";
            }

            SearchFilterType searchFilterType = SearchFilterType.Default;

            switch (videoSearchType)
            {
            case VideoSearchType.Videos:
                searchFilterType = SearchFilterType.Video;
                break;

            case VideoSearchType.Album:
            case VideoSearchType.PlayList:
            case VideoSearchType.Recommendation:
                searchFilterType = SearchFilterType.Playlist;
                break;

            case VideoSearchType.Mix:
            case VideoSearchType.All:
                searchFilterType = SearchFilterType.Default;
                break;

            case VideoSearchType.Channel:
                searchFilterType = SearchFilterType.Channel;
                break;

            case VideoSearchType.Rating:
                searchFilterType = SearchFilterType.Rating;
                break;
            }

            var data = await dataContext.SearchVideosByFilterAsync(searchText, pageNumber, pageSize, searchFilterType);

            return((string.IsNullOrEmpty(searchText) ? data.OrderByDescending(x => x.Statistics.ViewCount) : data.OrderBy(x => x.Title.Contains(searchText)).ThenByDescending(x => x.Statistics.ViewCount)).Select(x => Create(x)));
        }
Exemplo n.º 14
0
        private static PrivateApiResponseCode GetExpectedCode(FieldType fieldType, SearchFilterType searchFilterType)
        {
            var optionTypes     = new[] { FieldType.Option, FieldType.OptionCheckbox, FieldType.OptionDropdown, FieldType.OptionRadioButton };
            var dateFields      = new[] { FieldType.Age, FieldType.Date, FieldType.DateTime };
            var numericFields   = new[] { FieldType.Currency, FieldType.Number };
            var textFieldType   = new[] { FieldType.SingleLineText, FieldType.MultiLinesText, FieldType.Mail, FieldType.Url, FieldType.Telephone };
            var dateFilters     = new[] { SearchFilterType.Date, SearchFilterType.DateIn, SearchFilterType.DateMinMax };
            var numericFilters  = new[] { SearchFilterType.NumIn, SearchFilterType.NumMinMax, SearchFilterType.NumOperator };
            var textFilterTypes = new[] { SearchFilterType.Text };

            if ((dateFields.Contains(fieldType) && dateFilters.Contains(searchFilterType)) ||
                (numericFields.Contains(fieldType) && numericFilters.Contains(searchFilterType)) ||
                (textFieldType.Contains(fieldType) && textFilterTypes.Contains(searchFilterType)) ||
                searchFilterType == SearchFilterType.FreeWord ||
                ((searchFilterType == SearchFilterType.NumAll || searchFilterType == SearchFilterType.NumIn || searchFilterType == SearchFilterType.NumMinMax || searchFilterType == SearchFilterType.NumOperator) && optionTypes.Contains(fieldType)) ||
                (fieldType == FieldType.Age && numericFilters.Contains(searchFilterType)) ||
                (fieldType == FieldType.File && searchFilterType == SearchFilterType.Text))
            {
                return(PrivateApiResponseCode.OK);
            }
            return(PrivateApiResponseCode.InvalidParameter);
        }
Exemplo n.º 15
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> >());
            }
        }
Exemplo n.º 16
0
        public void SearchValidOperatorTests(ResourceId resourceId, SearchFilterType searchFilterType, FieldCategories fieldType)
        {
            var request = SearchRequestMapper[searchFilterType](resourceId, fieldType.ToString(), SearchValue);

            PerformSuccessfulSearchTest(resourceId, request, fieldType);
        }
        public void MultipleInvalidSearchCondition(ResourceId resource, OperatorType boolFilterType, SearchFilterType firstFilterType, SearchFilterType secondFilterType, string firstFieldName, string secondFieldName)
        {
            var searchFilters = new List <SearchFilter>();

            searchFilters.Add(SearchHelpers.SearchFilters[firstFilterType](resource, firstFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond));
            var secondSearchFilter = SearchHelpers.SearchFilters[secondFilterType](resource, secondFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond);

            secondSearchFilter.Operator = "Invalid Operator";
            searchFilters.Add(secondSearchFilter);
            var request  = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, searchFilters);
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
        public void MultipleValidSearchCondition(ResourceId resource, OperatorType boolFilterType, SearchFilterType firstFilterType, SearchFilterType secondFilterType, string firstFieldName, string secondFieldName)
        {
            var firstExpectedId  = RecordsCreatorForNumCond.Data[$"{resource}0"].Id;
            var secondExpectedId = RecordsCreatorForNumCond.Data[$"{resource}1"].Id;
            var searchFilters    = new List <SearchFilter>();

            searchFilters.Add(SearchHelpers.SearchFilters[firstFilterType](resource, firstFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond));
            searchFilters.Add(SearchHelpers.SearchFilters[secondFilterType](resource, secondFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond));
            var request  = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, searchFilters);
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            PrAssert.That(response?.Result?.Total, PrIs.Not.Null.And.GreaterThanOrEqualTo(1));

            if (boolFilterType == OperatorType.And)
            {
                if (TwoRecordsBeReturned(firstFilterType) && TwoRecordsBeReturned(secondFilterType))
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedId).And.Contains(secondExpectedId));
                }
                else
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedId).Or.Contains(secondExpectedId));
                }
            }
            else
            {
                PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedId).And.Contains(secondExpectedId));
            }
        }
        public void MultipleSearchWithDifferentCondition(ResourceId resource, OperatorType boolFilterType, SearchFilterType filterType, string fieldName)
        {
            var firstExpectedIdOfFirstCondition   = RecordsCreatorForFirstCondition.Data[$"{resource}0"].Id;
            var secondExpectedIdOfFirstCondition  = RecordsCreatorForFirstCondition.Data[$"{resource}1"].Id;
            var firstExpectedIdOfSecondCondition  = RecordsCreatorForSecondCondition.Data[$"{resource}0"].Id;
            var secondExpectedIdOfSecondCondition = RecordsCreatorForSecondCondition.Data[$"{resource}1"].Id;

            var searchFilters = ListSearchFilters[filterType](resource, fieldName, CurrentDateTime, Timezone);
            var request       = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, searchFilters);
            var handler       = new DefaultManager();
            var response      = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));

            if (boolFilterType == OperatorType.And)
            {
                if (filterType.ToString().Contains("Date") || filterType == SearchFilterType.FreeWord)
                {
                    PrAssert.That(response?.Result?.Total, PrIs.Not.Null.And.GreaterThanOrEqualTo(1));
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedIdOfFirstCondition).And.Contains(secondExpectedIdOfFirstCondition)
                                  .And.Contains(firstExpectedIdOfSecondCondition).And.Contains(secondExpectedIdOfSecondCondition));
                }
                else
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Null.Or.Empty);
                }
            }
            else
            {
                PrAssert.That(response?.Result?.Total, PrIs.Not.Null.And.GreaterThanOrEqualTo(1));

                if (filterType == SearchFilterType.NumIn || filterType == SearchFilterType.NumOperator)
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedIdOfFirstCondition).And.Contains(firstExpectedIdOfSecondCondition));
                }
                else
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedIdOfFirstCondition).And.Contains(secondExpectedIdOfFirstCondition)
                                  .Or.Contains(firstExpectedIdOfSecondCondition).And.Contains(secondExpectedIdOfSecondCondition));
                }
            }
        }
Exemplo n.º 20
0
        private static SearchFilterType createNameFilter(String name)
        {
            PropertyComplexValueFilterClauseType clause = new PropertyComplexValueFilterClauseType();
            clause.path = createItemPathType("name");
            clause.Item = name;

            SearchFilterType filter = new SearchFilterType();
            filter.Item = clause;
            filter.ItemElementName = ItemChoiceType1.equal;
            return filter;
        }
Exemplo n.º 21
0
        private static TestCaseData GetTestCaseData(SearchRequest request, ResourceId resource, SearchFilterType searchType, string op, PrivateApiResponseCode expectedCode)
        {
            var testCaseData = new TestCaseData(request, resource, searchType, op, expectedCode);

            var nullApplicableOperators = new List <string>
            {
                "=",
                "!="
            };

            if (searchType == SearchFilterType.BoolAndOr || searchType == SearchFilterType.BoolNot)
            {
                testCaseData.Bug("39352");
            }
            if (searchType == SearchFilterType.Subquery ||
                searchType == SearchFilterType.FreeWord ||
                searchType == SearchFilterType.DateMinMax ||
                searchType == SearchFilterType.NumMinMax)
            {
                testCaseData.Bug("39354");
            }
            if ((searchType == SearchFilterType.Text && !nullApplicableOperators.Contains(op)) ||
                (searchType == SearchFilterType.DateIn && !nullApplicableOperators.Contains(op)) ||
                (searchType == SearchFilterType.NumOperator && !nullApplicableOperators.Contains(op)) ||
                (searchType == SearchFilterType.Date && !nullApplicableOperators.Contains(op)))
            {
                testCaseData.Bug("39355");
            }

            return(testCaseData);
        }
Exemplo n.º 22
0
        private static SearchFilterType createRequestableFilter()
        {
            PropertyComplexValueFilterClauseType clause = new PropertyComplexValueFilterClauseType();
            clause.path = createItemPathType("requestable");
            clause.Item = true;

            SearchFilterType filter = new SearchFilterType();
            filter.Item = clause;
            filter.ItemElementName = ItemChoiceType1.equal;
            return filter;
        }
Exemplo n.º 23
0
        public void NullSearchValidationTest(SearchRequest request, ResourceId resource, SearchFilterType searchType, string operatorValue, PrivateApiResponseCode expectedCode)
        {
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            if (expectedCode == PrivateApiResponseCode.OK)
            {
                Assert.That(response, PrIs.SuccessfulResponse <SearchResponse>());
                PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            }
            else
            {
                Assert.That(response, PrIs.ErrorResponse().And.ErrorCode((int)expectedCode).And.HttpCode(400));
            }
        }
Exemplo n.º 24
0
        /// <inheritdoc />
        public async Task <IReadOnlyList <Video> > SearchVideosByFilterAsync(string query, int maxPages = 1, int pageSize = 20, SearchFilterType searchType = SearchFilterType.Default)
        {
            var videos = new List <Video>();

            for (var page = 1; page <= maxPages; page++)
            {
                var counter = 0;
                var doc     = await GetYoutubeHtmlResultAsync(query, page, searchType);

                var children = doc.GetElementsByClassName("item-section").FirstOrDefault()?.Children;
                if (children != null)
                {
                    foreach (HtmlElement videoItem in children)
                    {
                        var videoType = VideoType.Video;
                        if (videoItem.GetElementsByClassName("yt-lockup-playlist").Any())
                        {
                            videoType = VideoType.Playlist;
                        }
                        else if (videoItem.GetElementsByClassName("yt-lockup-channel").Any())
                        {
                            videoType = VideoType.Channel;
                        }
                        string         videoId;
                        string         thumbVideoId;
                        string         videoAuthor;
                        DateTimeOffset?videoUploadDate = null;  // Need help converting 1 year ago, 1 day ago etc. the problem is with the language. it could be diffrent
                        string         videoTitle;
                        string         videoDescription;
                        TimeSpan       videoDuration;
                        long           videoViewCount;
                        long           videoLikeCount    = 0;             // cant find this
                        long           videoDislikeCount = 0;             // cant find this
                        string[]       videoKeywords     = new string[0]; // are not available
                        int?           totalVideos;

                        ThumbnailSet videoThumbnails;
                        Statistics   videoStatistics;
                        if (videoType == VideoType.Channel)
                        {
                            videoId = videoItem.Find("[data-channel-external-id]").FirstOrDefault()?.GetAttribute("data-channel-external-id")?.Value;
                            if (string.IsNullOrEmpty(videoId))
                            {
                                videoId = videoItem.Find("a [href]").FirstOrDefault()?.GetAttribute("href")?.Value;
                            }
                            thumbVideoId = videoItem.Find(".video-thumb span img").FirstOrDefault()?.GetAttribute("src")?.Value;
                        }
                        else if (string.IsNullOrWhiteSpace(videoId = thumbVideoId = videoItem.Find("[data-context-item-id]").FirstOrDefault()?.GetAttribute("data-context-item-id").Value))
                        {
                            var idEl = videoItem.Find(".yt-lockup-thumbnail a [href]").FirstOrDefault();
                            if (idEl == null)
                            {
                                continue; // not valid div
                            }
                            var id = "youtube.com" + idEl?.GetAttribute("href").Value;
                            if (videoType != VideoType.Video)
                            {
                                videoId      = YoutubeClient.ParsePlaylistId(id);
                                thumbVideoId = YoutubeClient.ParseVideoId(id);
                            }
                            else
                            {
                                videoId = thumbVideoId = YoutubeClient.ParseVideoId(id);
                            }
                        }
                        if (string.IsNullOrWhiteSpace(videoTitle = videoItem.Find(".yt-lockup-title a span").FirstOrDefault()?.GetInnerText()))
                        {
                            videoTitle = videoItem.Find(".yt-lockup-title a").FirstOrDefault()?.GetInnerText();
                        }

                        if (videoTitle.IsDeletedVideo())
                        {
                            continue;
                        }

                        videoThumbnails  = new ThumbnailSet(thumbVideoId, videoType);
                        videoAuthor      = (videoItem.Find(".yt-lockup-byline a").FirstOrDefault()?.GetInnerText() ?? videoTitle).Split("-").FirstOrDefault();
                        videoDescription = videoItem.Find(".yt-lockup-description").FirstOrDefault()?.GetInnerText() ?? string.Empty;
                        videoDuration    = videoItem.Find(".video-time").FirstOrDefault()?.GetInnerText().ParseTime() ?? TimeSpan.FromSeconds(0);
                        videoViewCount   = videoItem.Find(".yt-lockup-meta-info li").LastOrDefault()?.GetInnerText()?.StripNonDigit().ParseLongOrDefault() ?? 0;
                        totalVideos      = videoItem.Find(".formatted-video-count-label").FirstOrDefault()?.GetInnerText().StripNonDigit().ParseIntOrDefault();
                        videoStatistics  = new Statistics(videoViewCount, videoLikeCount, videoDislikeCount);
                        videos.Add(new Video(videoId, videoAuthor, videoUploadDate, videoTitle, videoDescription, videoThumbnails, videoDuration, videoKeywords, videoStatistics, totalVideos, videoType));

                        if (counter >= pageSize)
                        {
                            break;
                        }
                        counter++;
                    }
                }
            }
            return(videos);
        }
        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);
 }
Exemplo n.º 27
0
        private async Task <HtmlDocument> GetYoutubeHtmlResultAsync(string query, int page, SearchFilterType searchType = SearchFilterType.Default)
        {
            string sp = "";

            switch (searchType)
            {
            case SearchFilterType.Default:
                sp = "";
                break;

            case SearchFilterType.Channel:
                sp = "EgIQAg%253D%253D";
                break;

            case SearchFilterType.Movie:
                sp = "EgIQBA%253D%253D";
                break;

            case SearchFilterType.Playlist:
                sp = "EgIQAw%253D%253D";
                break;

            case SearchFilterType.Video:
                sp = "EgIQAQ%253D%253D";
                break;

            case SearchFilterType.Rating:
                sp = "CAE%253D";
                break;
            }
            var url = new Uri($"https://www.youtube.com/results?search_query={query.UrlEncode()}&page={page}&sp={sp}&hl=en&disable_polymer=1");
            var raw = await _httpClient.GetStringAsync(url).ConfigureAwait(false); // don't ensure success but rather return empty list

            return(HtmlParser.Default.ParseDocument(raw));
        }
Exemplo n.º 28
0
 public void HappyPathTest_ApplicationFields(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, SearchFilterType searchType, string caseDescription, Func <SearchRequest> requestProvider)
 {
     PerformHappyPathTest(resource, requestProvider());
 }
Exemplo n.º 29
0
        public async Task LocalPackageSearchResource_SearchWithFilter_OnlyLatestVersionMatch(SearchFilterType searchFilter, bool includePrerelease, string expectedVersion)
        {
            using (var pathContext = new SimpleTestPathContext())
            {
                // Arrange
                string workingPath    = pathContext.WorkingDirectory;
                var    testLogger     = new TestLogger();
                string repositoryPath = Path.Combine(workingPath, "mypackages");
                string packageId      = "myPackage";
                var    packageA       = new SimpleTestPackageContext(packageId, "2.0.0-alpha.1.2+5");
                var    packageA2      = new SimpleTestPackageContext(packageId, "1.0.0");

                var packageContexts = new SimpleTestPackageContext[]
                {
                    packageA,
                    packageA2
                };

                await SimpleTestPackageUtility.CreatePackagesAsync(repositoryPath, packageContexts);

                FindLocalPackagesResourceV2 localResource = new FindLocalPackagesResourceV2(repositoryPath);
                LocalPackageSearchResource  resource      = new LocalPackageSearchResource(localResource);

                var filter = new SearchFilter(includePrerelease: includePrerelease, filter: searchFilter);

                // Act
                var matchingPackages = (await resource.SearchAsync(
                                            packageId,
                                            filter,
                                            skip: 0,
                                            take: 30,
                                            log: testLogger,
                                            token: CancellationToken.None))
                                       .OrderBy(p => p.Identity)
                                       .ToList();

                var matchPackage = matchingPackages.First();

                // Assert
                Assert.Equal(1, matchingPackages.Count);
                Assert.Equal(packageId, matchPackage.Identity.Id);
                Assert.Equal(expectedVersion, matchPackage.Identity.Version.ToFullString());
                Assert.Equal(0, testLogger.Warnings);
                Assert.Equal(0, testLogger.Errors);
            }
        }
Exemplo n.º 30
0
 public void SetFilter(SearchFilterType filterType)
 {
     Filter = filterType;
     OnFilterChange?.Invoke();
 }