예제 #1
0
        public void BuildPreSearchFilterOperationsTest(IEnumerable <KeyValuePair <string, int> > countOfFilters, IEnumerable <KeyValuePair <string, PreSearchFilterLogicalOperator> > filterFields, string expectedFilterBy)
        {
            var model = new PreSearchFiltersResultsModel
            {
                Sections = new List <FilterResultsSection>()
            };

            if (countOfFilters == null)
            {
                throw new TestException("Count Of Filters passed is null");
            }

            foreach (var item in countOfFilters)
            {
                var section = new FilterResultsSection
                {
                    SectionDataType     = item.Key,
                    Name                = item.Key,
                    Options             = GetTestFilterOptions(item).ToList(),
                    SingleSelectOnly    = item.Value == 1,
                    SingleSelectedValue = item.Value == 1 ? $"{item.Key.ToLower()}{item.Value}" : null
                };
                model.Sections.Add(section);
            }

            var testObject = new DfcBuildFilterService();
            var result     = testObject.BuildPreSearchFilters(model, filterFields.ToDictionary(k => k.Key, v => v.Value));

            result.Should().Be(expectedFilterBy);
        }
예제 #2
0
        public void GetIndexFieldDefinitionsTest(string input, int expectedOutPutCount, string expectedOutPut)
        {
            var buildFilterService    = new DfcBuildFilterService();
            var indexFieldDefinitions = buildFilterService.GetIndexFieldDefinitions(input);

            indexFieldDefinitions.Count().Should().Be(expectedOutPutCount);
            if (expectedOutPutCount > 0)
            {
                indexFieldDefinitions.FirstOrDefault().ToString().Should().BeEquivalentTo(expectedOutPut);
            }
        }
예제 #3
0
        public void GetSearchTermTests(string inputSearchFieldsSingular, string inputSearchFieldsPlural, string expcetedSearchTerm)
        {
            var buildFilterService = new DfcBuildFilterService();
            var searchProperties   = new SearchProperties();

            var preSearchFiltersResultsModel = new PreSearchFiltersResultsModel()
            {
                Sections = new List <FilterResultsSection>()
            };

            var testField1 = new FilterResultsOption()
            {
                ClearOtherOptionsIfSelected = false,
                IsSelected = true,
                OptionKey  = "Option1"
            };

            var testField2 = new FilterResultsOption()
            {
                ClearOtherOptionsIfSelected = false,
                IsSelected = true,
                OptionKey  = "Option2"
            };

            foreach (string field in inputSearchFieldsSingular.Split(','))
            {
                preSearchFiltersResultsModel.Sections.Add(new FilterResultsSection()
                {
                    SectionDataType  = field,
                    SingleSelectOnly = false,
                    Options          = new List <FilterResultsOption>()
                    {
                        testField1, testField2
                    }
                });
            }

            var searchTerm = buildFilterService.GetSearchTerm(searchProperties, preSearchFiltersResultsModel, inputSearchFieldsPlural.Split(','));

            searchTerm.Should().BeEquivalentTo(expcetedSearchTerm);
        }