コード例 #1
0
    public void CreatingAndRemovingTableInDB()
    {
        DBInstance dbInstance = new DBInstance("sensor_readings");

        dbInstance.InitialiseSQLiteConnection();

        string newTableName = "test";

        dbInstance.ExecuteNonQuery(
            SensorReadingTableDetails.CreateTableSQLString(newTableName));

        bool doesTableExistAfterCreation = dbInstance.DoesTableExistInDB(newTableName);

        Debug.Log("Table '" + newTableName + "' should now exist: " + doesTableExistAfterCreation);

        dbInstance.ExecuteNonQuery(
            SensorReadingTableDetails.DropTableSQLString(newTableName));

        bool doesTableExistAfterRemoved = dbInstance.DoesTableExistInDB(newTableName);

        Debug.Log("Table '" + newTableName + "' should now not exist: " + doesTableExistAfterRemoved);

        dbInstance.CloseSQLiteConnection();

        if ((doesTableExistAfterCreation) && (!doesTableExistAfterRemoved))
        {
            Assert.Pass();
        }
        else
        {
            Assert.Fail();
        }
    }