コード例 #1
0
        public void Should_Add_Products()
        {
            var repo = new GroceryRepository(_connection);

            const string name = "blabla";

            repo.AddProduct(name, false);

            var product = repo.GetProduct(name);

            Assert.IsNotNull(product);
            Assert.IsTrue(product.Name == name);

            repo.DeleteProduct(product.Id);
        }
コード例 #2
0
        public void Should_Add_Products_Add_To_Groceries()
        {
            var repo = new GroceryRepository(_connection);

            const string name = "blabla";

            repo.AddProduct(name, true);

            var product = repo.GetProduct(name);
            Assert.IsNotNull(product);
            Assert.IsTrue(product.Name == name);

            var grocery = repo.GetGroceryByProductId(product.Id);
            Assert.IsNotNull(grocery);

            repo.DeleteGrocery(grocery.ProductId);
            repo.DeleteProduct(product.Id);
        }
コード例 #3
0
        public void Should_Add_Grocery()
        {
            var repo = new GroceryRepository(_connection);

            const string name = "blabla";
            repo.AddProduct(name, false);
            var product = repo.GetProduct(name);

            repo.AddGrocery(product.Id);

            var grocery = repo.GetGroceryByProductId(product.Id);

            Assert.IsNotNull(grocery);
            Assert.IsTrue(grocery.ProductId == product.Id);

            repo.DeleteGrocery(product.Id);
            repo.DeleteProduct(product.Id);
        }
コード例 #4
0
        public void Should_return_Products_Not_In_Groceries()
        {
            var repo = new GroceryRepository(_connection);

            const string name = "blabla";

            repo.AddProduct(name, false);

            var prods = repo.GetProducts().ToList();

            Assert.IsNotNull(prods);
            Assert.IsTrue(prods.Any());

            var product = repo.GetProduct(name);
            repo.DeleteProduct(product.Id);
        }
コード例 #5
0
        public void Should_Return_Grocery_From_ProductId()
        {
            var repo = new GroceryRepository(_connection);

            const string name = "blabla";
            repo.AddProduct(name, false);
            var product = repo.GetProduct(name);
            repo.AddGrocery(product.Id);

            var groceries = repo.GetGroceries().ToList();
            Assert.IsTrue(groceries.Any());

            var groceryProduct = groceries.FirstOrDefault();
            Assert.IsNotNull(groceryProduct);

            var grocery = repo.GetGroceryByProductId(groceryProduct.ProductId);

            Assert.IsNotNull(grocery);
            Assert.IsTrue(grocery.ProductId == groceryProduct.ProductId);

            repo.DeleteGrocery(product.Id);
            repo.DeleteProduct(product.Id);
        }