Esempio n. 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();
        }
    }
Esempio n. 2
0
    public void InsertingSensorReading()
    {
        DBInstance dbInstance = new DBInstance("sensor_readings");

        dbInstance.InitialiseSQLiteConnection();

        string newTableName = "testTable";

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

        int numberOfRowsBeforeAddition = dbInstance.GetNumberOfRowsInTable(newTableName);

        Debug.Log("Number of rows in table before addition: " + numberOfRowsBeforeAddition);

        BaseSensorReading newSensorReading = new BaseSensorReading
        {
            sensorName = " ",
            sensorType = Sensor.Type.Interaction,
            areaName   = " "
        };

        newSensorReading.SetDateTime(1, 1, 1, 1, 1, 1);

        string insertSensorReadingString = SensorReadingTableDetails.InsertSensorReadingSQLString(newSensorReading, "testBookmark", 0, newTableName);

        Debug.Log(insertSensorReadingString);
        dbInstance.ExecuteNonQuery(insertSensorReadingString);

        int numberOfRowsAfterAddition = dbInstance.GetNumberOfRowsInTable(newTableName);

        Debug.Log("Number of rows in table after addition: " + numberOfRowsAfterAddition);

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

        if (numberOfRowsBeforeAddition == numberOfRowsAfterAddition - 1)
        {
            Assert.Pass();
        }
        else
        {
            Assert.Fail();
        }
    }
Esempio n. 3
0
 /// <summary>
 /// Utility method for transferring sensor readings, between a specified session IDs, between two tables
 /// in the connected database.
 /// </summary>
 /// <param name="fromTableName">Name of table who will be transferring sensor readings.</param>
 /// <param name="toTableName">Name of table who will be receiving the transferred sensor readings.</param>
 /// <param name="sessionIDStart">Lower bound of session IDs of sensor readings that will be transferred.</param>
 /// <param name="sessionIDEnd">Upper bound of session IDs of sensor readings that will be transferred.</param>
 public static void TransferSensorReadings(string fromTableName, string toTableName, int sessionIDStart, int sessionIDEnd)
 {
     dbInstance.ExecuteNonQuery(SensorReadingTableDetails.TransferSensorReadingsBetweenTablesSQLString(fromTableName, toTableName, sessionIDStart, sessionIDEnd));
 }
Esempio n. 4
0
 /// <summary>
 /// Utility, helper method for inserting a sensor reading into a table in the connected database.
 /// </summary>
 /// <param name="sensorReading">Sensor reading to be inserted.</param>
 /// <param name="bookmarkName">Name of bookmark associated with the sensor reading.</param>
 /// <param name="sessionID">Session ID associated with the sensor reading.</param>
 /// <param name="tableName">Name of table who will be storing the sensor reading.</param>
 public static void InsertSensorReadingInDatabaseTable(BaseSensorReading sensorReading, string bookmarkName, int sessionID, string tableName)
 {
     dbInstance.ExecuteNonQuery(SensorReadingTableDetails.InsertSensorReadingSQLString(sensorReading, bookmarkName, sessionID, tableName));
 }
Esempio n. 5
0
 /// <summary>
 /// Utility method which executes a SQL string to create a table in the database
 /// for sensor readings.
 /// </summary>
 /// <param name="tableName">Name of table to be created in the database.</param>
 public static void CreateTableInDatabaseForSensorReadings(string tableName)
 {
     dbInstance.ExecuteNonQuery(SensorReadingTableDetails.CreateTableSQLString(tableName));
 }