コード例 #1
0
        public void ShouldGetOrdersFromToday()
        {
            ProductTypeRepository repoPr = CreateRepositoryPr();
            OrderRepository       repoOr = CreateRepositoryOr();

            ProductType conditioner = repoPr.CreateProduct(8, 108, "Make your hair great again with this great conditioner!", 16);
            ProductType hairDye     = repoPr.CreateProduct(9, 571, "Don't like the disgusting color in your head? Change it now!", 52);

            List <int> productsId        = new List <int>();
            List <int> productsQuantity  = new List <int>();
            List <int> productsId1       = new List <int>();
            List <int> productsQuantity1 = new List <int>();

            productsId.Add(8);
            productsQuantity.Add(5);
            productsId.Add(9);
            productsQuantity.Add(10);

            productsId1.Add(9);
            productsQuantity1.Add(10);

            Order newOrder  = repoOr.InsertOrder(3, new DateTime(2016, 09, 20), new DateTime(2016, 09, 27), 1, productsQuantity, productsId, repoPr);
            Order newOrder1 = repoOr.InsertOrder(4, DateTime.Today, DateTime.Today, 2, productsQuantity1, productsId1, repoPr);

            List <Order> listOfTodaysOrders = repoOr.CheckOrders(DateTime.Today, repoPr);

            Assert.AreEqual(1, listOfTodaysOrders.Count);
        }
コード例 #2
0
        public void RegisteredShouldBeFalseWhenOrderIsCreated()
        {
            ProductTypeRepository repoPr = CreateRepositoryPr();
            OrderRepository       repoOr = CreateRepositoryOr();

            ProductType conditioner = repoPr.CreateProduct(8, 108, "Make your hair great again with this great conditioner!", 16);
            ProductType hairDye     = repoPr.CreateProduct(9, 571, "Don't like the disgusting color in your head? Change it now!", 52);

            List <int> productsId        = new List <int>();
            List <int> productsQuantity  = new List <int>();
            List <int> productsId1       = new List <int>();
            List <int> productsQuantity1 = new List <int>();

            productsId.Add(8);
            productsQuantity.Add(5);
            productsId.Add(9);
            productsQuantity.Add(10);

            productsId1.Add(9);
            productsQuantity1.Add(10);

            Order newOrder  = repoOr.InsertOrder(3, new DateTime(2016, 09, 20), new DateTime(2016, 09, 27), 1, productsQuantity, productsId, repoPr);
            Order newOrder1 = repoOr.InsertOrder(4, DateTime.Today, DateTime.Today, 2, productsQuantity1, productsId1, repoPr);

            Assert.IsFalse(newOrder.Registered);
            Assert.IsFalse(newOrder1.Registered);
        }
コード例 #3
0
        public void LoadOrder()
        {
            CustomerRepository repoCu = CreateRepositoryCu();

            repoCu.Clear();
            OrderRepository repoOr = CreateRepositoryOr();

            repoOr.Clear();

            Assert.AreEqual(0, repoCu.CountCustomers());
            Assert.AreEqual(0, repoOr.CountOrders());

            List <int> productsId       = new List <int>();
            List <int> productsQuantity = new List <int>();

            ProductTypeRepository repoPr = new ProductTypeRepository();

            ProductType hairSpray        = repoPr.CreateProduct(3, 68.00, "Supah stronk hair spray!", 10);
            ProductType hairStraightener = repoPr.CreateProduct(4, 172.62, "Very powerfull straightener for hair!", 30);

            productsId.Add(hairSpray.Id);
            productsQuantity.Add(5);
            productsId.Add(hairStraightener.Id);
            productsQuantity.Add(10);

            repoOr.InsertOrder(1, new DateTime(2015, 6, 10), new DateTime(2015, 7, 10), 1, productsQuantity, productsId, repoPr);

            Order loadedOrder = repoOr.Load(1);

            Assert.AreEqual(4, loadedOrder.ListOfOrderLines[1].ProductId);
        }
コード例 #4
0
        public void SaveAndCountTwoProducts()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer     = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);
            ProductType hairbrush = repo.CreateProduct(2, 39.00, "Very soft purple hair brush", 20);

            Assert.AreEqual(2, repo.CountProducts());
        }
コード例 #5
0
        public void CheckIfCanReturnDictionary()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);
            ProductType           shampoo  = repoPr.CreateProduct(7, 49.51, "Very foamy shampoo great for the whole famaly", 50);

            Dictionary <int, ProductType> listOfProducts = repoPr.GetProductTypes();

            Assert.AreEqual(2, listOfProducts.Count);
            Assert.AreEqual("Very Sharp scissors", listOfProducts[6].Description);
            Assert.AreEqual(49.51, listOfProducts[7].Price);
        }
コード例 #6
0
        public void SaveAndLoadTwoProducts()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer       = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);
            ProductType hairbrush   = repo.CreateProduct(2, 39.00, "Very soft purple hair brush", 20);
            ProductType loadedDryer = repo.Load(dryer.Id);
            ProductType loadedBrush = repo.Load(hairbrush.Id);

            Assert.AreEqual(dryer.Id, loadedDryer.Id);
            Assert.AreEqual(hairbrush.Id, loadedBrush.Id);
            Assert.AreNotEqual(loadedDryer.Id, loadedBrush.Id);
        }
コード例 #7
0
        public void CheckIfTheProductDoesNotExist()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            Assert.IsFalse(repoPr.CheckIfProductExists(7));
        }
コード例 #8
0
        public void CheckIfReturnsMinusOneWhenPassingANegativeNumber()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            int newAmount = repoPr.AddStock(6, -15);

            Assert.AreEqual(-1, newAmount);
        }
コード例 #9
0
        public void CheckIfReturnsMinusOneWhenPassingAProductThatDoesNotExist()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            int newAmount = repoPr.AddStock(7, 2);

            Assert.AreEqual(-1, newAmount);
        }
コード例 #10
0
        public void SaveAndCount()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);

            Assert.AreEqual(1, repo.CountProducts());
        }
コード例 #11
0
        public void CheckIfCanAddStock()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            int newAmount = repoPr.AddStock(6, 10);

            Assert.AreEqual(35, scissors.Amount);
            Assert.AreEqual(35, newAmount);
        }
コード例 #12
0
        public void SaveAndLoad()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer         = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);
            ProductType loadedProduct = repo.Load(dryer.Id);

            Assert.AreEqual(dryer.Id, loadedProduct.Id);
        }
コード例 #13
0
        public void ChangeProductAmount()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);

            repo.ChangeAmount(49, 1);

            Assert.AreEqual(49, dryer.Amount);
        }
コード例 #14
0
        public void ChangeProductPrice()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);

            repo.ChangePrice(20, 1);

            Assert.AreEqual(20, dryer.Price);
        }
コード例 #15
0
        public void Create()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);

            Assert.AreEqual(1, dryer.Id);
            Assert.AreEqual(263.00, dryer.Price);
            Assert.AreEqual("Very stronk pink hair dryer!!", dryer.Description);
            Assert.AreEqual(50, dryer.Amount);
            Assert.IsTrue(dryer.Id != 0);
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: Matt2694/PrettyHair-master
        public void InitializeProductTypeRepository()
        {
            repoPr.Clear();

            SqlCommand cmd = new SqlCommand("SP_GET_ALL_PRODUCTS", conn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            SqlDataReader rdr = cmd.ExecuteReader();

            if (rdr.HasRows)
            {
                while (rdr.Read())
                {
                    repoPr.CreateProduct(Convert.ToInt32(rdr["PRODUCT_ID"]), Convert.ToDouble(rdr["PRICE"]), rdr["DESCRIPTION"].ToString(), Convert.ToInt32(rdr["AMOUNT"]));
                }
            }
            rdr.Close();
        }
コード例 #17
0
        public void ShouldRegisterOrder()
        {
            ProductTypeRepository repoPr = CreateRepositoryPr();
            OrderRepository       repoOr = CreateRepositoryOr();

            ProductType conditioner = repoPr.CreateProduct(8, 108, "Make your hair great again with this great conditioner!", 16);

            List <int> productsId       = new List <int>();
            List <int> productsQuantity = new List <int>();

            productsId.Add(8);
            productsQuantity.Add(5);

            Order newOrder = repoOr.InsertOrder(3, new DateTime(2016, 09, 20), new DateTime(2016, 09, 27), 1, productsQuantity, productsId, repoPr);

            Assert.IsFalse(newOrder.Registered);

            repoOr.Register(1, repoPr);

            Assert.IsTrue(newOrder.Registered);
        }