Exemplo n.º 1
0
 public void SetUp()
 {
     options             = A.Fake <IFilterOptions>();
     options.BoringWords = new string[] { };
     wordReader          = new WordReaderTest();
     wordsAnalyzer       = new WordsAnalyzer(new Filter(options), wordReader);
 }
        public async Task <Metrics> GetSiteMetricsAsync(IFilterOptions filterOptions)
        {
            var prefix = api.Contains("?") ? $"{api}/system&" : $"{api}/system?";
            var url    = $"{prefix}{filterOptions.QueryString}";

            var httpResponseMessage = await httpClient.GetAsync(url);

            if (httpResponseMessage.IsSuccessStatusCode)
            {
                var responseString = await httpResponseMessage.Content.ReadAsStringAsync();

                if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.NoContent)
                {
                    return new Metrics()
                           {
                               HasContent = false
                           }
                }
                ;

                var response = JsonSerializer.Deserialize <Metrics>(responseString, defaultJsonSerializerOptions);
                response.HasContent = true;

                return(response);
            }
            else
            {
                return(new Metrics()
                {
                    HasContent = false
                });
            }
        }
    }
Exemplo n.º 3
0
 public ProgramOptions(IImageOptions imageOptions, IFontOptions fontOptions, IFilterOptions filterOptions,
                       string filePath)
 {
     ImageOptions  = imageOptions;
     FontOptions   = fontOptions;
     FilterOptions = filterOptions;
     FilePath      = filePath;
 }
Exemplo n.º 4
0
 private void Filter(IEnumerable <SettlementDTO> settlementDTOs, IFilterOptions filterOptions)
 {
     foreach (var settlementDTO in settlementDTOs.ToList())
     {
         Filter(settlementDTO.Children, filterOptions);
         if (_filter.IsTrue(settlementDTO, filterOptions) == false)
         {
             if (settlementDTO.Children.Any() == false)
             {
                 (settlementDTOs as List <SettlementDTO>).Remove(settlementDTO);
             }
         }
     }
 }
Exemplo n.º 5
0
        public async Task <IEnumerable <SettlementDTO> > FilterAsync(IFilterOptions filterOptions)
        {
            IEnumerable <Settlement> settlements = await Manager.Settlements.GetAllAsync();

            settlements = settlements.Where(s => s.ParentId == null);
            IEnumerable <SettlementDTO> settlementDTOs = _mapper.Map <IEnumerable <Settlement>, List <SettlementDTO> >(settlements);

            if (settlementDTOs.Any() == false)
            {
                return(settlementDTOs);
            }
            Filter(settlementDTOs, filterOptions);
            return(settlementDTOs);
        }
Exemplo n.º 6
0
        public async Task <IEnumerable <Diver> > GetAsync(IFilterOptions options)
        {
            IEnumerable <DiverPoco> pocos;

            if (options == null)
            {
                pocos = await _diverRepository.GetListAsync();
            }
            else
            {
                pocos = await _diverRepository.GetListAsync(options);
            }

            var divers = pocos.Select(p => _mapper.Map <Diver>(p));

            return(divers);
        }
Exemplo n.º 7
0
 public bool IsTrue(SettlementDTO settlementDTO, IFilterOptions filterOptions)
 {
     if (string.IsNullOrWhiteSpace(filterOptions.Name) != true &&
         settlementDTO.Nu.Contains(filterOptions.Name) == false)
     {
         return(false);
     }
     if (string.IsNullOrWhiteSpace(filterOptions.SettlementType) != true)
     {
         if (string.IsNullOrWhiteSpace(settlementDTO.Np) == true)
         {
             return(false);
         }
         if (settlementDTO.Np.Contains(filterOptions.SettlementType) == false)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initialize filters.
        /// </summary>
        /// <param name="options">Filter collection options.</param>
        /// <returns>Current filter collection.</returns>
        public IFilterCollection Init(IFilterOptions options)
        {
            _filtersOptions = options;

            if (_filtersOptions != null && _filtersOptions.Filters != null)
            {
                foreach (var filterOptions in _filtersOptions.Filters)
                {
                    if (!_filters.ContainsKey(filterOptions.Key))
                    {
                        continue;
                    }

                    var filter = _filters[filterOptions.Key];

                    filter.Init(filterOptions.Value);
                }
            }

            return(this);
        }
Exemplo n.º 9
0
        public async Task <IEnumerable <DiverPoco> > GetListAsync(IFilterOptions options)
        {
            var parameters = new
            {
                p_station_id          = options.RescueStationId,
                p_med_exam_start_date = options.MedicalExaminationStartDate,
                p_med_exam_end_date   = options.MedicalExaminationEndDate,
                p_min_qualif          = options.MinQualification,
                p_max_qualif          = options.MaxQualification,
                p_name_query          = options.NameQuery
            };

            string sql = "select * from divers";

            using (IDbConnection conn = Connection)
            {
                var diverpocos = await conn.QueryAsync <DiverPoco>(sql);

                return(diverpocos);
            }
        }
Exemplo n.º 10
0
 public void SetUp()
 {
     options       = new OptionsStub(0, 0);
     wordReader    = new WordReaderTest();
     wordsAnalyzer = new WordsAnalyzer(new Filter(options), wordReader);
 }
Exemplo n.º 11
0
 public static IEnumerable <TestExecutionData> ApplyToData(this IFilterOptions filters, IEnumerable <TestExecutionData> testData)
 {
     return(testData.ApplyFilters(filters));
 }
Exemplo n.º 12
0
 public Filter(IFilterOptions options)
 {
     boringWords    = options.BoringWords.Select(word => word.Normalize()).ToHashSet();
     mystemLocation = options.MystemLocation;
 }
Exemplo n.º 13
0
        public static IEnumerable <TestExecutionData> ApplyFilters(this IEnumerable <TestExecutionData> testData, IFilterOptions options)
        {
            var toReturn = testData;

            // Filter by test name
            if (!string.IsNullOrEmpty(options.TestName))
            {
                toReturn = toReturn.Where(t => t.TestCase.Name == options.TestName);
                if (toReturn.Count() == 1)
                {
                    return(toReturn);
                }
            }

            if (options.TestCategory != null)
            {
                toReturn = toReturn.Where(t => t.TestCategoryMatches(options.TestCategory) == true);
            }

            if (!string.IsNullOrEmpty(options.TestGroup))
            {
                toReturn = toReturn.Where(t => t.TestGroupName.Equals(options.TestGroup, StringComparison.InvariantCultureIgnoreCase));
            }

            return(toReturn);
        }
Exemplo n.º 14
0
 public async Task <PaginatedResponseDTO <List <Detection> > > GetUnconfirmedDetectionsAsync(PaginationOptionsDTO paginationOptions, IFilterOptions filterOptions)
 {
     return(await GetDetectionsAsync("unknowns", paginationOptions, filterOptions));
 }
Exemplo n.º 15
0
 public async Task <PaginatedResponseDTO <List <Detection> > > GetFalseDetectionsAsync(PaginationOptionsDTO paginationOptions, IFilterOptions filterOptions)
 {
     return(await GetDetectionsAsync("falsepositives", paginationOptions, filterOptions));
 }
Exemplo n.º 16
0
 // Get unreviewed detections
 public async Task <PaginatedResponseDTO <List <Detection> > > GetCandidateDetectionsAsync(PaginationOptionsDTO paginationOptions, IFilterOptions filterOptions)
 {
     return(await GetDetectionsAsync("unreviewed", paginationOptions, filterOptions));
 }
Exemplo n.º 17
0
        // Get detections based on passed view, pagination options, and filter options
        private async Task <PaginatedResponseDTO <List <Detection> > > GetDetectionsAsync(string viewName, PaginationOptionsDTO paginationOptions, IFilterOptions filterOptions)
        {
            var prefix = api.Contains("?") ? $"{api}/{viewName}&" : $"{api}/{viewName}?";
            var url    = $"{prefix}{paginationOptions.QueryString}&{filterOptions.QueryString}";

            var httpResponseMessage = await httpClient.GetAsync(url);

            if (httpResponseMessage.IsSuccessStatusCode)
            {
                var responseString = await httpResponseMessage.Content.ReadAsStringAsync();

                if (string.IsNullOrWhiteSpace(responseString))
                {
                    return new PaginatedResponseDTO <List <Detection> > {
                               Response = new List <Detection>(), TotalAmountPages = 0, TotalNumberRecords = 0
                    }
                }
                ;

                return(new PaginatedResponseDTO <List <Detection> >
                {
                    Response = JsonSerializer.Deserialize <List <Detection> >(responseString, defaultJsonSerializerOptions),
                    TotalAmountPages = int.Parse(httpResponseMessage.Headers.GetValues("totalAmountPages").FirstOrDefault()),
                    TotalNumberRecords = int.Parse(httpResponseMessage.Headers.GetValues("totalNumberRecords").FirstOrDefault())
                });
            }
            else
            {
                return(new PaginatedResponseDTO <List <Detection> > {
                    Response = null, TotalAmountPages = 0, TotalNumberRecords = 0
                });
            }
        }