public void BaseStationDBHistory_Constructor_Initialises_To_Known_State_And_Properties_Work() { var record = new BaseStationDBHistory(); TestUtilities.TestProperty(record, "DBHistoryID", 0, 1202); TestUtilities.TestProperty(record, "Description", null, "ANV"); TestUtilities.TestProperty(record, "TimeStamp", DateTime.MinValue, DateTime.Now); }
public void BaseStationDBHistory_IsCreationOfDatabaseByVirtualRadarServer_Returns_True_When_Matching_Description_Seen() { var record = new BaseStationDBHistory(); Assert.IsFalse(record.IsCreationOfDatabaseByVirtualRadarServer); record.Description = "Database autocreated by Virtual Radar Server"; Assert.IsTrue(record.IsCreationOfDatabaseByVirtualRadarServer); record.Description = "DATABASE AUTOCREATED BY VIRTUAL RADAR SERVER"; Assert.IsTrue(record.IsCreationOfDatabaseByVirtualRadarServer); record.Description = "Database created by Snoopy"; Assert.IsFalse(record.IsCreationOfDatabaseByVirtualRadarServer); }
private long AddDBHistory(BaseStationDBHistory dbHistory) { long result = 0; using(var connection = new SQLiteConnection(_ConnectionStringBuilder.ConnectionString)) { connection.Open(); using(var command = connection.CreateCommand()) { command.CommandText = "INSERT INTO [DBHistory] ([TimeStamp], [Description]) VALUES (?,?); SELECT last_insert_rowid();"; command.Parameters.Add(new SQLiteParameter() { Value = dbHistory.TimeStamp }); command.Parameters.Add(new SQLiteParameter() { Value = dbHistory.Description }); result = (long)command.ExecuteScalar(); dbHistory.DBHistoryID = (int)result; } } return result; }
/// <summary> /// Inserts a new record and returns its identifier. /// </summary> /// <param name="connection"></param> /// <param name="transaction"></param> /// <param name="log"></param> /// <param name="dbHistory"></param> /// <returns></returns> public int Insert(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationDBHistory dbHistory) { var preparedCommand = PrepareInsert(connection, transaction, "Insert", "DBHistoryID", "TimeStamp", "Description"); return (int)Sql.ExecuteInsert(preparedCommand, log, dbHistory.TimeStamp, dbHistory.Description); }