コード例 #1
0
        public void DAO_FindByKeywordsAndCategoryTest_WithCategory()
        {
            int            numberFoundProducts = 1;
            int            numberProducts      = 2;
            List <Product> createdProducts     = new List <Product>();

            for (int i = 0; i < numberProducts; i++)
            {
                product                 = new Product();
                product.productName     = productName + i;
                product.productPrice    = productPrice;
                product.productDate     = productDate;
                product.productQuantity = productQuantity;
                product.Category        = category;

                productDao.Create(product);
                if (i == 1)
                {
                    createdProducts.Add(product);
                }

                product                 = new Product();
                product.productName     = "name" + i;
                product.productPrice    = productPrice;
                product.productDate     = productDate;
                product.productQuantity = productQuantity;
                product.categoryId      = category2.categoryId;

                productDao.Create(product);
            }

            List <Product> totalRetrievedProducts = productDao.FindByKeywords("1", category.categoryId);

            Assert.AreEqual(numberFoundProducts, totalRetrievedProducts.Count);

            for (int i = 0; i < numberFoundProducts; i++)
            {
                Assert.AreEqual(totalRetrievedProducts[i], createdProducts[i]);
            }
        }