Esempio n. 1
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();
        }
    }