Esempio n. 1
0
        //数据库StockHold读测试
        public void DBDataControllerStockHoldTest()
        {
            File.Delete(Environment.CurrentDirectory + "\\Stock4.db");
            DBDataController DBC = new DBDataController("user9", Environment.CurrentDirectory + "\\Stock4.db");
            DB_ERROR         DBE = DBC.GetLastError();
            DealListEntity   DLE = new DealListEntity();

            DLE.id     = "600001";
            DLE.name   = "邯郸钢铁";
            DLE.money  = 10.11;
            DLE.number = 400;
            DLE.type   = "买入";
            DBC.DealListAdd(DLE);//存入一条数据
            DLE.id     = "600001";
            DLE.name   = "邯郸钢铁";
            DLE.money  = 5.11;
            DLE.number = 200;
            DLE.type   = "卖出";
            DBC.DealListAdd(DLE);//再存入一条数据
            List <StockHoldEntity> SHEL;

            DBC.StockHoldReadAll(out SHEL);
            Assert.AreEqual(1, SHEL.Count);
            Assert.AreEqual(DLE.id, SHEL[0].id);  //判断读取与存入的数据是否一致
            Assert.AreEqual(DLE.name, SHEL[0].name);
            Assert.AreEqual(200, SHEL[0].hold);   //运算结果
            Assert.AreEqual(3022, SHEL[0].money); //运算结果
        }
Esempio n. 2
0
        //数据库DealList读写测试
        public void DBDataControllerDealListTest()
        {
            File.Delete(Environment.CurrentDirectory + "\\Stock1.db");
            DBDataController DBC = new DBDataController("user6", Environment.CurrentDirectory + "\\Stock1.db");
            DB_ERROR         DBE = DBC.GetLastError();
            DealListEntity   DLE = new DealListEntity();

            DLE.id   = "600001";
            DLE.name = "邯郸钢铁";
            DBC.DealListAdd(DLE);//存入一条数据
            List <DealListEntity> DLEL;

            DBC.DealListReadAll(out DLEL);       //读取
            Assert.AreEqual(1, DLEL.Count);
            Assert.AreEqual(DLE.id, DLEL[0].id); //判断读取与存入的数据是否一致
            Assert.AreEqual(DLE.name, DLEL[0].name);
        }