Exemple #1
0
        public void Test_Filtering_After_All_Features_Longer_list_Features_Order_should_NOT_matter()
        {
            //Given
            Feature firstFeature = new Feature {
                Id = 2
            };
            Feature secondFeature = new Feature {
                Id = 3
            };
            Feature thirdFeature = new Feature {
                Id = 4
            };

            ProductType apples = new ProductType
            {
                Name     = "apples",
                Features = new List <Feature> {
                    firstFeature
                }
            };
            ProductType pears = new ProductType
            {
                Name     = "apples",
                Features = new List <Feature> {
                    secondFeature
                }
            };
            ProductType nuts = new ProductType
            {
                Name     = "nuts",
                Features = new List <Feature> {
                    thirdFeature, secondFeature, firstFeature
                }
            };
            ProductType watermelons = new ProductType
            {
                Name     = "watermelons",
                Features = new List <Feature> {
                    firstFeature, secondFeature, firstFeature
                }
            };

            var productList = new List <ProductType> {
                apples, pears, nuts, watermelons
            };

            //When
            var filteringCriteria = new List <Feature> {
                firstFeature, secondFeature, thirdFeature
            };
            var filter       = new ListFilter(productList, filteringCriteria);
            var filteredList = filter.AllFeaturesFilter();

            //Then
            Assert.Single(filteredList);
        }
Exemple #2
0
        public void Test_Filtering_After_All_Features_list_of_2_Products()
        {
            //Given
            Feature firstFeature = new Feature {
                Id = 2
            };
            Feature secondFeature = new Feature {
                Id = 3
            };

            ProductType apples = new ProductType
            {
                Name     = "apples",
                Features = new List <Feature> {
                    firstFeature, secondFeature
                }
            };
            ProductType pears = new ProductType
            {
                Name     = "pears",
                Features = new List <Feature> {
                    secondFeature
                }
            };

            var productList = new List <ProductType> {
                apples, pears
            };

            //When
            var filteringCriteria = new List <Feature> {
                firstFeature, secondFeature
            };
            var filter       = new ListFilter(productList, filteringCriteria);
            var filteredList = filter.AllFeaturesFilter();

            //Then
            Assert.Single(filteredList);
        }
Exemple #3
0
        public void Test_AllFeaturesFilter()
        {
            ProductType prod1 = new ProductType
            {
                Name     = "prod1",
                Features = new List <Feature> {
                    new Feature {
                        Id = 1
                    },
                    new Feature {
                        Id = 2
                    },
                    new Feature {
                        Id = 3
                    },
                    new Feature {
                        Id = 4
                    }
                }
            };

            ProductType prod2 = new ProductType
            {
                Name     = "prod2",
                Features = new List <Feature> {
                    new Feature {
                        Id = 2
                    },
                    new Feature {
                        Id = 3
                    }
                }
            };

            ProductType prod3 = new ProductType
            {
                Name     = "prod3",
                Features = new List <Feature> {
                    new Feature {
                        Id = 2
                    },
                    new Feature {
                        Id = 1
                    }
                }
            };

            var productList = new List <ProductType> {
                prod1, prod2, prod3
            };

            var filteringCriteria = new List <Feature> {
                new Feature {
                    Id = 2
                }, new Feature {
                    Id = 3
                }
            };
            var filter       = new ListFilter(productList, filteringCriteria);
            var filteredList = filter.AllFeaturesFilter();

            Assert.Equal(2, filteredList.Count());
            Assert.Equal(prod1, filteredList.First());
            Assert.Equal(prod2, filteredList.Last());
        }