コード例 #1
0
ファイル: CashDescView.cs プロジェクト: EnjoyNN/CrmModel
        public CashDescView(CashDesc cashDesc, int number, int x, int y)
        {
            this.cashDesc = cashDesc;

            cashDescName        = new Label();
            price               = new NumericUpDown();
            queueLength         = new ProgressBar();
            leaveCustomersCount = new Label();

            cashDescName.AutoSize = true;
            cashDescName.Location = new System.Drawing.Point(x, y);
            cashDescName.Name     = "label" + number;
            cashDescName.Size     = new System.Drawing.Size(35, 13);
            cashDescName.TabIndex = number;
            cashDescName.Text     = cashDesc.ToString();

            price.Location = new System.Drawing.Point(x + 70, y);
            price.Name     = "numericUpDown" + number;
            price.Size     = new System.Drawing.Size(120, 20);
            price.TabIndex = number;
            price.Maximum  = 1000000000000000;

            queueLength.Location = new System.Drawing.Point(x + 250, y);
            queueLength.Maximum  = cashDesc.maxQueueLength;
            queueLength.Name     = "progressBar" + number;
            queueLength.Size     = new System.Drawing.Size(100, 23);
            queueLength.TabIndex = number;
            queueLength.Value    = 0;

            leaveCustomersCount.AutoSize = true;
            leaveCustomersCount.Location = new System.Drawing.Point(x + 400, y);
            leaveCustomersCount.Name     = "label2" + number;
            leaveCustomersCount.Size     = new System.Drawing.Size(35, 13);
            leaveCustomersCount.TabIndex = number;
            leaveCustomersCount.Text     = "";

            cashDesc.checkClosed += CashDesc_checkClosed;
        }
コード例 #2
0
ファイル: CashDescTests.cs プロジェクト: EnjoyNN/CrmModel
        public void CashDescTest()
        {
            //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()
            {
                ProductId = 1,
                Name      = "testProduct1",
                Price     = 100,
                Count     = 10
            };

            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "testProduct2",
                Price     = 150,
                Count     = 66
            };

            var cart1 = new Cart(customer1);

            cart1.addProduct(product1);
            cart1.addProduct(product1);
            cart1.addProduct(product2);

            var cart2 = new Cart(customer2);

            cart2.addProduct(product1);
            cart2.addProduct(product2);
            cart2.addProduct(product2);

            var cashDesc = new CashDesc(1, seller);

            cashDesc.maxQueueLength = 10;
            cashDesc.Enqueue(cart1);
            cashDesc.Enqueue(cart2);

            var cart1ExpectedResult = 350;
            var cart2ExpectedResult = 400;

            //act
            //извлечение товаров из очереди и подсчет
            var cart1ActualResult = cashDesc.Dequeue();
            var cart2ActualResult = cashDesc.Dequeue();

            //assert
            Assert.AreEqual(cart1ExpectedResult, cart1ActualResult);
            Assert.AreEqual(cart2ExpectedResult, cart2ActualResult);
            //проверяем что количетсво товара на складе уменьшилось. было 10 одного и 66 другого. поэтому минус 3 у каждого.
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(63, product2.Count);
        }