public void BaseStationSystemEvents_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            var record = new BaseStationSystemEvents();

            TestUtilities.TestProperty(record, "App", null, "Ab");
            TestUtilities.TestProperty(record, "Msg", null, "Hn");
            TestUtilities.TestProperty(record, "SystemEventsID", 0, 123);
            TestUtilities.TestProperty(record, "TimeStamp", DateTime.MinValue, DateTime.Now);
        }
 public void DeleteSystemEvent(BaseStationSystemEvents systemEvent)
 {
     ;
 }
 public void UpdateSystemEvent(BaseStationSystemEvents systemEvent)
 {
     ;
 }
 public void InsertSystemEvent(BaseStationSystemEvents systemEvent)
 {
     ;
 }
        private long AddSystemEvent(BaseStationSystemEvents systemEvent)
        {
            long result = 0;

            using(var connection = new SQLiteConnection(_ConnectionStringBuilder.ConnectionString)) {
                connection.Open();

                using(var command = connection.CreateCommand()) {
                    command.CommandText = "INSERT INTO [SystemEvents] ([App], [Msg], [TimeStamp]) VALUES (?,?,?); SELECT last_insert_rowid();";
                    command.Parameters.Add(new SQLiteParameter() { Value = systemEvent.App });
                    command.Parameters.Add(new SQLiteParameter() { Value = systemEvent.Msg });
                    command.Parameters.Add(new SQLiteParameter() { Value = systemEvent.TimeStamp });

                    result = (long)command.ExecuteScalar();
                    systemEvent.SystemEventsID = (int)result;
                }
            }

            return result;
        }
        public void BaseStationDatabase_InsertSystemEvents_Correctly_Inserts_Record()
        {
            _Database.WriteSupportEnabled = true;

            var timestamp = DateTime.Now;
            var systemEvent = new BaseStationSystemEvents() { App = "123456789.12345", Msg = new String('X', 100), TimeStamp = timestamp };

            _Database.InsertSystemEvent(systemEvent);
            Assert.AreNotEqual(0, systemEvent.SystemEventsID);

            var readBack = _Database.GetSystemEvents()[0];
            Assert.AreEqual(systemEvent.SystemEventsID, readBack.SystemEventsID);
            Assert.AreEqual("123456789.12345", readBack.App);
            Assert.AreEqual(new String('X', 100), readBack.Msg);
            Assert.AreEqual(TruncateDate(timestamp), readBack.TimeStamp);
        }
 /// <summary>
 /// Inserts a new record and returns the ID.
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="transaction"></param>
 /// <param name="log"></param>
 /// <param name="systemEvent"></param>
 /// <returns></returns>
 public int Insert(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationSystemEvents systemEvent)
 {
     var preparedCommand = PrepareInsert(connection, transaction, "Insert", "SystemEventsID", "TimeStamp", "App", "Msg");
     return (int)Sql.ExecuteInsert(preparedCommand, log, systemEvent.TimeStamp, systemEvent.App, systemEvent.Msg);
 }
 /// <summary>
 /// Deletes the record passed across.
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="transaction"></param>
 /// <param name="log"></param>
 /// <param name="systemEvent"></param>
 public void Delete(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationSystemEvents systemEvent)
 {
     var preparedCommand = PrepareCommand(connection, transaction, "Delete", _DeleteCommandText, 1);
     Sql.SetParameters(preparedCommand, systemEvent.SystemEventsID);
     Sql.LogCommand(log, preparedCommand.Command);
     preparedCommand.Command.ExecuteNonQuery();
 }
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="systemEvent"></param>
        public void DeleteSystemEvent(BaseStationSystemEvents systemEvent)
        {
            if(!WriteSupportEnabled) throw new InvalidOperationException("You cannot delete a system event record when write support is disabled");

            lock(_ConnectionLock) {
                OpenConnection();
                if(_Connection != null) _SystemEventsTable.Delete(_Connection, _TransactionHelper.Transaction, _DatabaseLog, systemEvent);
            }
        }
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="systemEvent"></param>
        public void InsertSystemEvent(BaseStationSystemEvents systemEvent)
        {
            if(!WriteSupportEnabled) throw new InvalidOperationException("You cannot insert a system event record when write support is disabled");

            systemEvent.TimeStamp = SQLiteDateHelper.Truncate(systemEvent.TimeStamp);

            lock(_ConnectionLock) {
                OpenConnection();
                if(_Connection != null) systemEvent.SystemEventsID = _SystemEventsTable.Insert(_Connection, _TransactionHelper.Transaction, _DatabaseLog, systemEvent);
            }
        }