public static void ExecuteBySqlTest() { StringBuilder sbCreateTableSql = new StringBuilder(); //附属信息 sbCreateTableSql.Append("Create table ControllerAttachedInfo(ID in9teger not null primary key autoincrement,controllerID integer not null,FileVersion varchar(4), ProtocolVersion varchar(4));"); string strDBFile = "E:\\test.db"; //_logHelper = Substitute.For<SCA.Interface.ILogRecorder>(); _dbConn = new SCA.DatabaseAccess.SQLiteDatabaseAccess(strDBFile, _logHelper, _fileService); int returnValue = _dbConn.ExecuteBySql(sbCreateTableSql); //Assert.AreEqual(0, returnValue); // _dbConn.Dispose(); //ILogRecorder _logHelper; //IFileService _fileService; //IDatabaseService _dbConn;// = new SCA.DatabaseAccess.SQLiteDatabaseAccess("test.db", logHelper); //StringBuilder sbCreateTableSql = new StringBuilder(); ////附属信息 //sbCreateTableSql.Append("Create table ControllerAttachedInfo(ID integer not null primary key autoincrement,controllerID integer not null,FileVersion varchar(4), ProtocolVersion varchar(4));"); //string strDBFile = "test.db"; //_logHelper = Substitute.For<SCA.Interface.ILogRecorder>(); //_fileService = Substitute.For<SCA.Interface.IFileService>(); //_dbConn = new SCA.DatabaseAccess.SQLiteDatabaseAccess(strDBFile, _logHelper, _fileService); //int returnValue = _dbConn.ExecuteBySql(sbCreateTableSql); // Assert.AreEqual(0, returnValue); //_dbConn.Dispose(); }
public void GetDataListBySQLTest() { IList <LoopModel> lstLoopModel = new List <LoopModel>(); StringBuilder sbCreateTableSql = new StringBuilder(); //回路信息 sbCreateTableSql.Append("Create table Loop(id integer not null primary key autoincrement,name varchar(20),Code varchar(6),controllerID int,DeviceAmount int );"); _dbConn = new DatabaseAccess.SQLiteDatabaseAccess(strDBFile, _logHelper, _fileService); _dbConn.ExecuteBySql(sbCreateTableSql); _dbConn.ExecuteBySql(new StringBuilder("insert into Loop(id,name,Code,controllerID,DeviceAmount) values(1,'william','0101',1,55)")); lstLoopModel = (List <LoopModel>)_dbConn.GetDataListBySQL <SCA.Model.LoopModel>(new StringBuilder("select * from Loop")); Assert.AreEqual(1, lstLoopModel.Count); }
public void ExecuteBySqlTest() { StringBuilder sbCreateTableSql = new StringBuilder(); //附属信息 sbCreateTableSql.Append("Create table ControllerAttachedInfo(ID integer not null primary key autoincrement,controllerID integer not null,FileVersion varchar(4), ProtocolVersion varchar(4));"); _dbConn = new DatabaseAccess.SQLiteDatabaseAccess(strDBFile, _logHelper, _fileService); int returnValue = _dbConn.ExecuteBySql(sbCreateTableSql); Assert.AreEqual(0, returnValue); }
public void GetObjectValueTest() { StringBuilder sbCreateTableSql = new StringBuilder(); //附属信息 sbCreateTableSql.Append("Create table ControllerAttachedInfo2(ID integer not null primary key autoincrement,controllerID integer not null,FileVersion varchar(4), ProtocolVersion varchar(4));"); _dbConn = new DatabaseAccess.SQLiteDatabaseAccess(strDBFile, _logHelper, _fileService); _dbConn.ExecuteBySql(sbCreateTableSql); int intControllerAttachedInfoNum = Convert.ToInt16(_dbConn.GetObjectValue(new StringBuilder("select count(*) from ControllerAttachedInfo2"))); Assert.AreEqual(0, intControllerAttachedInfoNum); //_dbConn.Dispose(); }
public static void GetObjectValueTest() { StringBuilder sbCreateTableSql = new StringBuilder(); //附属信息 sbCreateTableSql.Append("Create table ControllerAttachedInfo2(ID integer not null primary key autoincrement,controllerID integer not null,FileVersion varchar(4), ProtocolVersion varchar(4));"); string strDBFile = "E:\\test.db"; //_logHelper = Substitute.For<SCA.Interface.ILogRecorder>(); //_fileService = new SCA.BusinessLib.Utility.FileService(); _dbConn = new SCA.DatabaseAccess.SQLiteDatabaseAccess(strDBFile, _logHelper, _fileService); _dbConn.ExecuteBySql(sbCreateTableSql); int intControllerAttachedInfoNum = Convert.ToInt16(_dbConn.GetObjectValue(new StringBuilder("select count(*) from Co9ntrollerAttachedInfo2"))); _dbConn.Dispose(); }
public void CreateTableOf8001() { StringBuilder sbCreateTableSql = new StringBuilder(); //附属信息 sbCreateTableSql.Append("Create table ControllerAttachedInfo(ID integer not null primary key autoincrement,controllerID integer not null,FileVersion varchar(4), ProtocolVersion varchar(4));"); //回路表 sbCreateTableSql.Append("Create table Loop(id integer not null primary key autoincrement,name varchar(20),Code varchar(6),controllerID int,DeviceAmount int );"); _logHelper = Substitute.For <SCA.Interface.ILogRecorder>(); _dbConn.ExecuteBySql(sbCreateTableSql); int intControllerAttachedInfoNum = Convert.ToInt16(_dbConn.GetObjectValue(new StringBuilder("select count(*) from ControllerAttachedInfo"))); int intLoopNum = Convert.ToInt16(_dbConn.GetObjectValue(new StringBuilder("select count(*) from Loop"))); Assert.AreEqual(0, intControllerAttachedInfoNum); // Assert.AreEqual(0, intLoopNum);//不知为什么查出的结果会是1 _dbConn.Dispose(); }