Ejemplo n.º 1
0
        public void Mains_Should_Throw_ArgumentNullException_If_ProductCategories_Is_Null()
        {
            IQueryable <ProductCategory> productCategories = null;

            var ex = Assert.Throws <ArgumentNullException>(() => ProductCategoryExtensions.Mains(productCategories));

            Assert.Equal(nameof(productCategories), ex.ParamName);
        }
Ejemplo n.º 2
0
        public void Mains_Should_Return_Only_Categories_Set_As_Main_Category()
        {
            IQueryable <ProductCategory> productCategories = new ProductCategory[]
            {
                new ProductCategory {
                    CategoryId = Guid.NewGuid(), ProductId = Guid.NewGuid(), IsMain = true
                },
                new ProductCategory {
                    CategoryId = Guid.NewGuid(), ProductId = Guid.NewGuid(), IsMain = true
                },
                new ProductCategory {
                    CategoryId = Guid.NewGuid(), ProductId = Guid.NewGuid(), IsMain = false
                }
            }.AsQueryable();

            var mainCategories = ProductCategoryExtensions.Mains(productCategories).ToArray();

            Assert.True(mainCategories.All(c => c.IsMain));
        }