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 TestAddStockItem()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            Assert.IsTrue(p.InsertStock("Apple", 0.5, 1, 100));
        }
Exemplo n.º 3
0
        public void TestDisplaySalesRecord()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            //Assert.IsTrue(p.DisplayReceipt(0));
        }
Exemplo n.º 4
0
        public void TestDeleteStockItem()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            p.InsertStock("Apple", 0.5, 1, 100);
            StockRecord lid = p.RequestStockInfo(-1)[0];

            Assert.IsTrue(p.DeleteStock(lid.StockID));
        }
Exemplo n.º 5
0
        public void TestAddSalesRecord()
        {
            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);

            //List<ItemSale> s = new List<ItemSale>;

            //Assert.IsTrue(p.AddNewReceipt(0,s));
        }
Exemplo n.º 6
0
        public void TestPredictNextMonthSales()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

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

            s.Add(1);
            s.Add(2);
            s.Add(3);
            var    watch = System.Diagnostics.Stopwatch.StartNew();
            double t     = p.PredictNextMonthSales(s);

            watch.Stop();
            Assert.IsTrue(t.Equals(0));
            var elapsedMs = watch.ElapsedMilliseconds;

            Assert.IsTrue(elapsedMs < 30000);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
 private void btn_connect_Click(object sender, EventArgs e)
 {
     _connection = new ClientConnectionManager(txt_ip.Text, int.Parse(txt_port.Text));
     _connection.ConnectToServer();
 }
Exemplo n.º 9
0
        public void TestEditSalesRecord()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());
        }