コード例 #1
0
        public void CashDeskTest()
        {
            //arrange
            var customer1 = new Customer()
            {
                Name       = "TestUser1",
                CustomerID = 1
            };
            var customer2 = new Customer()
            {
                Name       = "TestUser2",
                CustomerID = 2
            };
            var seller = new Seller()
            {
                Name     = "TestSeller",
                SellerID = 1
            };
            var product1 = new Product()
            {
                Name = "TestPR1", Price = 5, Count = 5, ProductID = 1
            };
            var product2 = new Product()
            {
                Name = "TestPR2", Price = 10, Count = 10, ProductID = 2
            };
            var cart1 = new Cart(customer1);
            var cart2 = new Cart(customer2);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            cart2.Add(product2);
            cart2.Add(product2);
            var cashDesk = new CashDesk(1, seller);

            cashDesk.MaxQueueLenght = 10;
            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);

            var cart1Res = 20;
            var cart2Res = 20;
            //act
            var cart1ActualResult = cashDesk.Dequeue();
            var cart2ActualResult = cashDesk.Dequeue();


            //assert
            Assert.AreEqual(cart1Res, cart1ActualResult);
            Assert.AreEqual(cart2Res, cart2ActualResult);

            Assert.AreEqual(3, product1.Count);
            Assert.AreEqual(7, product2.Count);
        }
コード例 #2
0
        public void CashDeskTest()
        {
            //Arrange
            Customer customer1 = new Customer()
            {
                Name = "test1", CustomerId = 1
            };
            Customer customer2 = new Customer()
            {
                Name = "test2", CustomerId = 2
            };
            Product product1 = new Product()
            {
                Name = "pr1", Count = 10, Price = 1, ProductId = 1
            };
            Product product2 = new Product()
            {
                Name = "pr2", Count = 10, Price = 2, ProductId = 2
            };
            Cart   cart1  = new Cart(customer1);
            Cart   cart2  = new Cart(customer2);
            Seller seller = new Seller()
            {
                Name = "seller1", SellerId = 1
            };
            CashDesk cashDesk = new CashDesk(seller, 1);

            cashDesk.maxLenght = 10;
            cashDesk.isModel   = true;
            //Act
            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            cart2.Add(product2);
            cart2.Add(product2);
            cart2.Add(product1);

            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);

            decimal result1 = cashDesk.Dequeue();
            decimal result2 = cashDesk.Dequeue();

            //Assert
            Assert.AreEqual(4, result1);
            Assert.AreEqual(5, result2);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(7, product2.Count);
        }
コード例 #3
0
        private void ButtonPay_Click(object sender, EventArgs e)
        {
            if (customer != null)
            {
                cashDesk = new CashDesk(1, SetRandomSeller(), dbContext)
                {
                    IsModel = false
                };

                cashDesk.Enqueue(cusrtomerCart);
                var price = cashDesk.Dequeue();
                CartList.Items.Clear();
                cusrtomerCart = new Cart(customer);
                SetFullPrice();
                ButtonPay.Enabled = false;

                MessageBox.Show("Покупка выполнена успешно." +
                                $" Сумма: {price} руб.", "Покупка выполнена",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Авторизуйтесь, пожалуйста!", "Ошибка авторизации",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #4
0
        public void DequeueTest()
        {
            // Arrange
            var customer1 = new Customer()
            {
                Id   = 1,
                Name = "testuser1"
            };

            var customer2 = new Customer()
            {
                Id   = 2,
                Name = "testuser2"
            };

            var seller = new Seller()
            {
                Id   = 1,
                Name = "sellerTest",
            };

            var product1 = new Product()
            {
                Id    = 1,
                Name  = "pr1",
                Price = 100,
                Count = 10
            };

            var product2 = new Product()
            {
                Id    = 2,
                Name  = "prod2",
                Price = 200,
                Count = 20
            };
            var cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            var cart2 = new Cart(customer2);

            cart2.Add(product2);
            cart2.Add(product1);
            cart2.Add(product2);
            var cashdesk = new CashDesk(1, seller, null, 2);

            // Act
            cashdesk.Enqueue(cart1);
            cashdesk.Enqueue(cart2);
            cashdesk.Dequeue();

            // Assert
            Assert.AreEqual(1, cashdesk.Queue.Count);
        }
コード例 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (customer != null)
     {
         cashDesk.Enqueue(cart);
         cashDesk.Dequeue();
     }
     {
         MessageBox.Show("Авторизуйтесь, пожалуйста", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #6
0
ファイル: Main.cs プロジェクト: Rullazzz/CrmModelShop
 private void Paybutton_Click(object sender, EventArgs e)
 {
     if (_customer != null)
     {
         _cashDesk.Enqueue(_cart);
         var price = _cashDesk.Dequeue();
         ClearCart();
         MessageBox.Show($"Покупка выполнена успешно! \nСумма: {price}", "Покупка выполнена", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Пожалуйста, авторизуйтесь", "Ошибочка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #7
0
ファイル: Main.cs プロジェクト: mbponline/CrmShop
 private void button1_Click(object sender, EventArgs e)
 {
     if (customer != null)
     {
         cashDesk.Enqueue(cart);
         var price = cashDesk.Dequeue();
         listBox2.Items.Clear();
         cart = new Cart(customer);
         MessageBox.Show("Purchased for: " + price, " successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Please log in", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (customer != null)
     {
         cashDesk.Enqueu(cart);
         var price = cashDesk.Dequeue();
         listBox2.Items.Clear();
         cart = new Cart(customer);
         MessageBox.Show($"Покупка выполнена успешно. Сумма: {price}", "Покупка выполнена", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Авторизуйтесь, пожалуйста", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #9
0
ファイル: Main.cs プロジェクト: Artem-Astakhov/CrmMotorola
 private void button1_Click(object sender, EventArgs e)
 {
     if (customer != null)
     {
         cashDesk.Enqueue(cart);
         cashDesk.Dequeue();
     }
     else
     {
         MessageBox.Show("Login", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     cart = new Cart(customer);
     listBox2.Items.Clear();
     label1.Text = "0";
 }
コード例 #10
0
ファイル: main.cs プロジェクト: aiserrock/CrmModelTest
        //кнопка Pay
        private void button1_Click(object sender, EventArgs e)
        {
            if (customer != null)
            {
                cashDesk.Enqueue(cart);
                var price = cashDesk.Dequeue();
                listBox2.Items.Clear();
                cart = new Cart(customer);

                MessageBox.Show("Buying complite succsesfull. Amount: " + price, " Buying complite", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Log in, please", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (customer != null)
            {
                CashDesk.Enqueue(cart);
                var price = CashDesk.Dequeue();
                listBox2.Items.Clear();
                cart = new Cart(customer);

                MessageBox.Show("Покупка выполнена. Сумма " + price);
            }
            else
            {
                MessageBox.Show("Авторизуйтесь", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: Fedoop1/CRMModelShop
        private void BuyButton_Click(object sender, EventArgs e)
        {
            if (isLogin)
            {
                desk.Enqueue(cart);
                decimal sum = desk.Dequeue();

                cart = new Cart(customer);
                UpdateBoxed();

                MessageBox.Show($"Покупка успешно проведена. Сумма покупки: {sum} руб.", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show($"Вы не авторизованы!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Сделать проверку на забивку корзины Main.cs сделать удаление в чеках
            if (customer != null && cart.Price != null)
            {
                cashDesk.Enqueue(cart);
                var price = cashDesk.Dequeue();
                listBox2.Items.Clear();
                cart = new Cart(customer);

                MessageBox.Show($"Поздравляю с оформлением покупки! Сумма покупки-{price}", "Покупка выполнена", MessageBoxButtons.OK, MessageBoxIcon.Information);
                label1.Text = "Итого:";
            }
            else
            {
                MessageBox.Show("Авторизуйтесь в приложении", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #14
0
ファイル: Main.cs プロジェクト: kanilZ/CrmBL
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (customer != null)
            {
                cashDesk.Enqueue(cart);
                var price = cashDesk.Dequeue();
                if (price != 0)
                {
                    listBox2.Items.Clear();
                    cart = new Cart(customer);

                    MessageBox.Show($"Придбання виконано успішно. Загальна вартість: {price}", "Придбання виконано", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Ви нічого не купили", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Авторизуйтесь, будь-ласка", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #15
0
        public void CashDeskTest()
        {
            // Arrange
            var customer1 = new Customer()
            {
                Id   = 1,
                Name = "testuser1"
            };

            var customer2 = new Customer()
            {
                Id   = 2,
                Name = "testuser2"
            };

            var seller = new Seller()
            {
                Id   = 1,
                Name = "sellerTest",
            };

            var product1 = new Product()
            {
                Id    = 1,
                Name  = "pr1",
                Price = 100,
                Count = 10
            };

            var product2 = new Product()
            {
                Id    = 2,
                Name  = "prod2",
                Price = 200,
                Count = 20
            };
            var cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            var cart2 = new Cart(customer1);

            cart2.Add(product2);
            cart2.Add(product1);
            cart2.Add(product2);

            var cashdesk = new CashDesk(1, seller, null);

            cashdesk.Enqueue(cart1);
            cashdesk.Enqueue(cart2);

            var cartExpectedResult1 = 400;
            var cartExpectedResult2 = 500;

            // Act
            var cartResult1 = cashdesk.Dequeue();
            var cartResult2 = cashdesk.Dequeue();

            // Assert
            Assert.AreEqual(cartExpectedResult1, cartResult1);
            Assert.AreEqual(cartExpectedResult2, cartResult2);
        }
コード例 #16
0
ファイル: CashDeskTests.cs プロジェクト: Vrg26/Crm
        public void CashDeskTest()
        {
            //Arrange
            var customer1 = new Customer()
            {
                Name       = "testuser1",
                CustomerId = 1
            }; var customer2 = new Customer()

            {
                Name       = "testuser2",
                CustomerId = 2
            };
            var seller = new Seller()
            {
                Name     = "sellername",
                SellerId = 1
            };

            var produt1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            var produt2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200,
                Count     = 20
            };
            var cart1 = new Cart(customer1);

            cart1.Add(produt1);
            cart1.Add(produt1);
            cart1.Add(produt2);

            var cart2 = new Cart(customer2);

            cart2.Add(produt1);
            cart2.Add(produt2);
            cart2.Add(produt2);

            var cashdesk = new CashDesk(1, seller);

            cashdesk.MaxQueueLenght = 10;

            cashdesk.Enqueue(cart1);
            cashdesk.Enqueue(cart2);

            var cart1ExpectedResult = 400;
            var cart2ExpectedResult = 500;

            //Act

            var cart1ActualResult = cashdesk.Dequeue();
            var cart2ActualResult = cashdesk.Dequeue();


            //Assert

            Assert.AreEqual(cart1ExpectedResult, cart1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, cart2ActualResult);
            Assert.AreEqual(7, produt1.Count);
            Assert.AreEqual(17, produt2.Count);
        }
コード例 #17
0
        public void CashDeskTest()
        {
            //arrange
            Customer customer1 = new Customer()
            {
                Name       = "Tester1",
                CustomerId = 1,
            };

            Customer customer2 = new Customer()
            {
                Name       = "Tester2",
                CustomerId = 2,
            };

            Seller seller = new Seller()
            {
                Name     = "SellerTest",
                SellerId = 1
            };

            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200,
                Count     = 20
            };

            var card1 = new Card(customer1);

            card1.Add(product1);
            card1.Add(product1);
            card1.Add(product2);
            var card2 = new Card(customer2);

            card2.Add(product1);
            card2.Add(product2);
            card2.Add(product2);
            var chashDesk = new  CashDesk(1, seller);

            chashDesk.MaxQueueLenght = 10;

            chashDesk.Enqueue(card1);
            chashDesk.Enqueue(card2);

            var card1Result = 400;
            var card2Result = 500;

            //act
            var card1ActualResult = chashDesk.Dequeue();
            var card2ActualResult = chashDesk.Dequeue();

            //assert
            Assert.AreEqual(card1Result, card1ActualResult);
            Assert.AreEqual(card2Result, card2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(17, product2.Count);
        }
コード例 #18
0
        public void CashDeskTest()
        {
            //arrange
            var customer1 = new Customer()
            {
                CustomerId = 1,
                Name       = "testUser1",
            };
            var customer2 = new Customer()
            {
                CustomerId = 2,
                Name       = "testUser2",
            };
            var seller = new Seller()
            {
                SellerId = 5,
                Name     = "Garry"
            };
            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100M,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200M,
                Count     = 5
            };
            var cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);
            var cart2 = new Cart(customer2);

            cart2.Add(product1);
            cart2.Add(product2);
            cart2.Add(product2);
            cart2.Add(product2);
            var cashdesk = new CashDesk(1, seller);

            cashdesk.Enqueue(cart1);
            cashdesk.Enqueue(cart2);

            var expectedCart1Result = 400;
            var expectedCart2Result = 700;


            //act
            var cart1ActualResult = cashdesk.Dequeue();
            var cart2ActualResult = cashdesk.Dequeue();

            //assert

            Assert.AreEqual(expectedCart1Result, cart1ActualResult);
            Assert.AreEqual(expectedCart2Result, cart2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(1, product2.Count);
        }
コード例 #19
0
        public void CashDeskTest()
        {
            // Arrange
            var customer1 = new Customer()
            {
                CustomerId = 1,
                Name       = "TestUser1"
            };

            var customer2 = new Customer()
            {
                CustomerId = 2,
                Name       = "TestUser2"
            };

            var seller = new Seller()
            {
                SellerId = 1,
                Name     = "SellerName"
            };

            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };

            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200,
                Count     = 20
            };

            var cart1 = new Cart(customer1)
            {
                product1,
                product1,
                product2
            };

            var cart2 = new Cart(customer2)
            {
                product1,
                product2,
                product2
            };

            var cashDesk = new CashDesk(1, seller, null)
            {
                MaxQueueLength = 10
            };

            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);

            var cart1ExpectedResult = 400;
            var cart2ExpectedResult = 500;

            // Act
            var cart1ActualResult = cashDesk.Dequeue();
            var cart2ActualResult = cashDesk.Dequeue();

            // Assert
            Assert.AreEqual(cart1ExpectedResult, cart1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, cart2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(17, product2.Count);
        }
コード例 #20
0
        public void CashDeskTest()
        {
            //arrange **обьявление данных входные/итоговые
            var customer1 = new Customer()
            {
                Name       = "testuser1",
                CustomerId = 1,
            };
            var customer2 = new Customer()
            {
                Name       = "testuser2",
                CustomerId = 2,
            };
            var seller = new Seller()
            {
                Name     = "sellername",
                SellerId = 1
            };
            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "prod3",
                Price     = 200,
                Count     = 20
            };


            var cart1 = new Cart(customer1);
            var cart2 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            cart2.Add(product1);
            cart2.Add(product2);
            cart2.Add(product2);

            var cashdesk = new CashDesk(1, seller, null);

            cashdesk.MaxQueueLenght = 10;
            cashdesk.Enqueue(cart1);
            cashdesk.Enqueue(cart2);

            //Expected result
            var cart1ExpectedResult = 400;
            var cart2ExpectedResult = 500;

            //act **выполнение действия

            var cart1ActualResult = cashdesk.Dequeue();
            var cart2ActualResult = cashdesk.Dequeue();

            //assert **сравнение ожидаемого/фактического
            Assert.AreEqual(cart1ExpectedResult, cart1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, cart2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(17, product2.Count);
        }
コード例 #21
0
        public void CashDeskTest()
        {
            // arrange
            var customer1 = new Customer()
            {
                Name       = "testUser1",
                CustomerId = 2
            };

            var customer2 = new Customer()
            {
                Name       = "testUser2",
                CustomerId = 2
            };

            var seller = new Seller()
            {
                Name     = "testSeller",
                SellerId = 1
            };

            var product1 = new Product
            {
                ProductId = 1,
                Name      = "first product",
                Price     = 100,
                Count     = 10
            };

            var product2 = new Product
            {
                ProductId = 2,
                Name      = "second product",
                Price     = 200,
                Count     = 20
            };

            var cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product2);


            var cart2 = new Cart(customer2);

            cart2.Add(product1);
            cart2.Add(product1);

            var cashDesk = new CashDesk(1, seller);

            cashDesk.MaxQueueLength = 10;
            cashDesk.Endqueue(cart1);
            cashDesk.Endqueue(cart2);

            decimal cartExpectedRes1 = 300;
            decimal cartExpectedRes2 = 200;

            // act
            var carActualRes1 = cashDesk.Dequeue();
            var carActualRes2 = cashDesk.Dequeue();

            // assert
            Assert.AreEqual(carActualRes1, cartExpectedRes1);
            Assert.AreEqual(carActualRes2, cartExpectedRes2);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(19, product2.Count);
        }
コード例 #22
0
ファイル: CashDeskTests.cs プロジェクト: Yersen/CRM-SYSTEM
        public void CashDeskTest()
        {
            //arrange
            var customer1 = new Customer()
            {
                Name       = "testUser1",
                CustomerID = 1
            };
            var customer2 = new Customer()
            {
                Name       = "testUser2",
                CustomerID = 2
            };
            var seller = new Seller()
            {
                Name     = "sellerName",
                SellerID = 1
            };

            var product1 = new Product()//продукты в магазине
            {
                ProductID = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductID = 2,
                Name      = "prod3",
                Price     = 200,
                Count     = 20
            };
            var cart1 = new Cart(customer1);//продукты в корзине у покупателя

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            var cart2 = new Cart(customer2);

            cart2.Add(product1);
            cart2.Add(product2);
            cart2.Add(product2);

            var cashDesk = new CashDesk(1, seller, null);

            cashDesk.MaxQueueLenght = 10;
            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);

            var cart1ExpectedResult = 400;
            var cart2ExpectedResult = 500;
            //act
            var car1ActualResult = cashDesk.Dequeue();
            var car2ActualResult = cashDesk.Dequeue();

            //assert
            Assert.AreEqual(cart1ExpectedResult, car1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, car2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(17, product2.Count);
        }
コード例 #23
0
        public void CashDeskTest()
        {
            //Arrange
            Customer customer1 = new Customer()
            {
                CustomerId = 1,
                Name       = "testUser1"
            };

            Customer customer2 = new Customer()
            {
                CustomerId = 2,
                Name       = "testUser2"
            };

            Seller seller = new Seller()
            {
                SellerId = 1,
                Name     = "testSeller"
            };

            Product product1 = new Product()
            {
                ProductId = 1,
                Name      = "productTest1",
                Price     = 100,
                Count     = 10,
            };

            Product product2 = new Product()
            {
                ProductId = 2,
                Name      = "productTest2",
                Price     = 200,
                Count     = 20,
            };

            Cart cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            Cart cart2 = new Cart(customer2);

            cart2.Add(product1);
            cart2.Add(product2);
            cart2.Add(product2);

            CashDesk cashDesk = new CashDesk(1, seller, null);

            cashDesk.MaxQueueLenght = 10;
            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);

            int cartResult1 = 400;
            int cartResult2 = 500;

            //Act
            decimal cartActualResult1 = cashDesk.Dequeue();
            decimal cartActualResult2 = cashDesk.Dequeue();

            //Assert
            Assert.AreEqual(cartResult1, cartActualResult1);
            Assert.AreEqual(cartResult2, cartActualResult2);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(17, product2.Count);
        }
コード例 #24
0
ファイル: CashDeskTests.cs プロジェクト: kanilZ/CrmBL
        public void CashDeskTest()
        {
            //arrange
            var customer1 = new Customer()
            {
                Name       = "Test1User",
                CustomerId = 1
            };
            var customer2 = new Customer()
            {
                Name       = "Test2User",
                CustomerId = 2
            };
            var seller = new Seller()
            {
                Name     = "TestSeller",
                SellerId = 1
            };
            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200,
                Count     = 20
            };
            var cart1 = new Cart(customer1);
            var cart2 = new Cart(customer2);

            var cashDesk = new CashDesk(1, seller, null);

            cashDesk.MaxQueueLenght = 10;
            var cart1ExpectedResult = 400;
            var cart2ExpectedResult = 300;

            //act
            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            cart2.Add(product1);
            cart2.Add(product2);

            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);

            var cart1ActualResult = cashDesk.Dequeue();
            var cart2ActualResult = cashDesk.Dequeue();

            //assert
            Assert.AreEqual(cart1ExpectedResult, cart1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, cart2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(18, product2.Count);
        }
コード例 #25
0
        public void CashDeskTest()
        {
            //arrange
            var customer1 = new Customer()
            {
                Name       = "TestVik",
                CustomerId = 1
            };
            var customer2 = new Customer()
            {
                Name       = "TestAndrew",
                CustomerId = 2
            };
            var seller = new Seller()
            {
                Name     = "SellerLi",
                SellerId = 1
            };
            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "prod1",
                Price     = 100,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "prod2",
                Price     = 500,
                Count     = 10
            };
            var cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product1);
            cart1.Add(product2);

            var cart2 = new Cart(customer2);

            cart2.Add(product1);
            cart2.Add(product1);
            cart2.Add(product1);
            cart2.Add(product2);
            cart2.Add(product2);

            var cartDesk = new CashDesk(1, seller);

            cartDesk.MaxQueueLength = 10;
            cartDesk.Enqueue(cart1);
            cartDesk.Enqueue(cart2);

            var cart1Result = 700;
            var cart2Result = 1300;

            //act
            var cart1ActualResult = cartDesk.Dequeue();
            var cart2ActualResult = cartDesk.Dequeue();

            //assert

            Assert.AreEqual(cart1Result, cart1ActualResult);
            Assert.AreEqual(cart2Result, cart2ActualResult);
            Assert.AreEqual(5, product1.Count);
            Assert.AreEqual(7, product2.Count);
        }
コード例 #26
0
ファイル: CashDeckTests.cs プロジェクト: stepanov039/CrmModel
        public void CashDeckTest()
        {
            //arrange
            var customer1 = new Customer()
            {
                Name       = "test",
                CustomerId = 1
            };
            var customer2 = new Customer()
            {
                Name       = "test2",
                CustomerId = 2
            };

            var seller = new Seller()
            {
                SellerId = 1,
                Name     = "Продовец 1"
            };

            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "Товар 1",
                Count     = 10,
                Price     = 11
            };

            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "Товар 2",
                Count     = 20,
                Price     = 21
            };

            var product3 = new Product()
            {
                ProductId = 3,
                Name      = "Товар 3",
                Count     = 30,
                Price     = 31
            };


            var cart1 = new Cart(customer1);

            cart1.Add(product1);
            cart1.Add(product2);
            cart1.Add(product3);


            var cart2 = new Cart(customer2);

            cart2.Add(product1);
            cart2.Add(product2);
            cart2.Add(product2);
            cart2.Add(product1);

            var cashDesk = new CashDesk(1, seller);

            cashDesk.Enqueue(cart1);
            cashDesk.Enqueue(cart2);


            var cart1ExpectedResult = 63;
            var cart2ExpectedResult = 64;
            //act

            var cart1ActualResult = cashDesk.Dequeue();
            var cart2ActualResult = cashDesk.Dequeue();

            //assert

            Assert.AreEqual(cart1ExpectedResult, cart1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, cart2ActualResult);
        }