Exemplo n.º 1
0
        public void TestEditReceipt()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            p.InsertStock("Apple", 0.5, 1, 100);
            p.InsertStock("Orange", 0.7, 1.5, 100);
            p.InsertStock("Banana", 0.65, 1.2, 100);

            int lenReceipt = p.RequestStockInfo(-1).Count - 1;

            StockRecord aRecord = p.RequestStockInfo(-1)[lenReceipt];
            StockRecord bRecord = p.RequestStockInfo(-1)[lenReceipt - 1];
            StockRecord cRecord = p.RequestStockInfo(-1)[lenReceipt - 2];

            ItemSaleRecord a = new ItemSaleRecord(0, aRecord.StockID, 1, 1);
            ItemSaleRecord b = new ItemSaleRecord(0, bRecord.StockID, 1.5, 2);
            ItemSaleRecord c = new ItemSaleRecord(0, cRecord.StockID, 1.2, 1);


            List <ItemSaleRecord> s = new List <ItemSaleRecord>();

            s.Add(a);
            s.Add(b);
            s.Add(c);

            Assert.IsTrue(p.InsertReceipt(s));

            int lenReceiptNew = p.RequestReceiptInfo(-1).Count - 1;

            ReceiptRecord aReceipt = (ReceiptRecord)p.RequestReceiptInfo(-1)[lenReceiptNew];

            Assert.IsTrue(p.UpdateReceipt(aReceipt.SaleID));
        }
Exemplo n.º 2
0
        public void TestAddReceipt()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            p.DeleteReceipt(-1);
            p.DeleteStock(-1);

            p.InsertStock("Apple", 0.5, 1, 100);
            p.InsertStock("Orange", 0.7, 1.5, 100);
            p.InsertStock("Banana", 0.65, 1.2, 100);

            int lenStock = p.RequestStockInfo(-1).Count - 1;

            List <StockRecord> records = p.RequestStockInfo(-1);
            StockRecord        aRecord = records[lenStock];
            StockRecord        bRecord = records[lenStock - 1];
            StockRecord        cRecord = records[lenStock - 2];

            ItemSaleRecord a = new ItemSaleRecord(0, aRecord.StockID, 1, 1);
            ItemSaleRecord b = new ItemSaleRecord(0, bRecord.StockID, 1.5, 2);
            ItemSaleRecord c = new ItemSaleRecord(0, cRecord.StockID, 1.2, 1);


            List <ItemSaleRecord> s = new List <ItemSaleRecord>();

            s.Add(a);
            s.Add(b);
            s.Add(c);

            Assert.IsTrue(p.InsertReceipt(s));


            int lenReceiptNew = p.RequestReceiptInfo(-1).Count - 1;

            //ReceiptRecord lastReceipt = (ReceiptRecord)p.RequestReceiptInfo(-1)[lenReceiptNew];
            Assert.IsTrue(p.RequestReceiptInfo(-1).Count == 1);
        }