示例#1
0
        public void Test_Filtering_After_NO_Feature_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> {
                    new Feature {
                        Id = 4
                    }
                }
            };
            ProductType pears = new ProductType
            {
                Name     = "pears",
                Features = new List <Feature> {
                    new Feature {
                        Id = 5
                    }
                }
            };
            ProductType nuts = new ProductType
            {
                Name     = "nuts",
                Features = new List <Feature> {
                    secondFeature, new Feature {
                        Id = 5
                    }
                }
            };

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

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

            //Then
            Assert.Equal(2, filteredList.Count());
        }
示例#2
0
        public void Test_Filtering_After_NO_Feature_Should_Not_Consider_Features_ORDER()
        {
            //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> {
                    thirdFeature
                }
            };
            ProductType pears = new ProductType
            {
                Name     = "pears",
                Features = new List <Feature> {
                    secondFeature, thirdFeature, firstFeature
                }
            };
            ProductType nuts = new ProductType
            {
                Name     = "nuts",
                Features = new List <Feature> {
                    secondFeature, firstFeature
                }
            };

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

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

            //Then
            Assert.Empty(filteredList);
        }
示例#3
0
        public void Test_NoFeatureFilter()
        {
            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 = 1
                    },
                    new Feature {
                        Id = 4
                    }
                }
            };

            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.NoFeatureFilter();

            Assert.Single(filteredList);
            Assert.Equal(prod2, filteredList.First());
            Assert.Equal(prod2, filteredList.Last());
        }