Exemple #1
0
        public void SOLID_OCP_Test4()
        {
            var betterFilter = new BetterFilter();

            var filteredProductNamesByColorAndSize = new List <string>();

            var largeGreenSpec = Color.Green.And(Size.Small);

            foreach (var item in betterFilter.Filter(products, largeGreenSpec))
            {
                filteredProductNamesByColorAndSize.Add(item.Name);
            }

            IEnumerable <string> expectedProductNames = products.Where(q => q.Color == Color.Green && q.Size == Size.Small)
                                                        .Select(q => q.Name);

            Assert.IsTrue(HelperTest.AreEquals(expectedProductNames, filteredProductNamesByColorAndSize.ToArray(), order: true));
        }
Exemple #2
0
        public void SOLID_OCP_Test1()
        {
            IEnumerable <string> expectedProductNames = new List <string>();

            var betterFilter = new BetterFilter();

            List <string> filteredProductNamesByColor = new List <string>(3);

            foreach (var item in betterFilter.Filter(products, new ColorSpecification(Color.Green)))
            {
                filteredProductNamesByColor.Add(item.Name);
            }

            expectedProductNames = products.Where(q => q.Color == Color.Green)
                                   .Select(q => q.Name);

            Assert.IsTrue(HelperTest.AreEquals(expectedProductNames, filteredProductNamesByColor.ToArray(), order: true));
        }