/// <summary> /// Copies the object's values to an aircraft. /// </summary> /// <param name="aircraft"></param> public void ApplyTo(BaseStationAircraft aircraft) { aircraft.AircraftClass = AircraftClass; aircraft.CofACategory = CofACategory; aircraft.CofAExpiry = CofAExpiry; aircraft.Country = Country; aircraft.CurrentRegDate = CurrentRegDate; aircraft.DeRegDate = DeRegDate; aircraft.Engines = Engines; aircraft.FirstCreated = FirstCreated; aircraft.FirstRegDate = FirstRegDate; aircraft.GenericName = GenericName; aircraft.ICAOTypeCode = ICAOTypeCode; aircraft.InfoUrl = InfoUrl; aircraft.Interested = Interested; aircraft.LastModified = LastModified; aircraft.Manufacturer = Manufacturer; aircraft.ModeS = ModeS; aircraft.ModeSCountry = ModeSCountry; aircraft.MTOW = MTOW; aircraft.OperatorFlagCode = OperatorFlagCode; aircraft.OwnershipStatus = OwnershipStatus; aircraft.PictureUrl1 = PictureUrl1; aircraft.PictureUrl2 = PictureUrl2; aircraft.PictureUrl3 = PictureUrl3; aircraft.PopularName = PopularName; aircraft.PreviousID = PreviousID; aircraft.Registration = Registration; aircraft.RegisteredOwners = RegisteredOwners; aircraft.SerialNo = SerialNo; aircraft.Status = Status; aircraft.TotalHours = TotalHours; aircraft.Type = Type; aircraft.UserNotes = UserNotes; aircraft.UserTag = UserTag; aircraft.YearBuilt = YearBuilt; aircraft.UserString1 = UserString1; aircraft.UserString2 = UserString2; aircraft.UserString3 = UserString3; aircraft.UserString4 = UserString4; aircraft.UserString5 = UserString5; aircraft.UserBool1 = UserBool1; aircraft.UserBool2 = UserBool2; aircraft.UserBool3 = UserBool3; aircraft.UserBool4 = UserBool4; aircraft.UserBool5 = UserBool5; aircraft.UserInt1 = UserInt1; aircraft.UserInt2 = UserInt2; aircraft.UserInt3 = UserInt3; aircraft.UserInt4 = UserInt4; aircraft.UserInt5 = UserInt5; }
/// <summary> /// Creates a new object. /// </summary> /// <param name="aircraft"></param> public BaseStationAircraftUpsert(BaseStationAircraft aircraft) { AircraftClass = aircraft.AircraftClass; CofACategory = aircraft.CofACategory; CofAExpiry = aircraft.CofAExpiry; Country = aircraft.Country; CurrentRegDate = aircraft.CurrentRegDate; DeRegDate = aircraft.DeRegDate; Engines = aircraft.Engines; FirstCreated = aircraft.FirstCreated; FirstRegDate = aircraft.FirstRegDate; GenericName = aircraft.GenericName; ICAOTypeCode = aircraft.ICAOTypeCode; InfoUrl = aircraft.InfoUrl; Interested = aircraft.Interested; LastModified = aircraft.LastModified; Manufacturer = aircraft.Manufacturer; ModeS = aircraft.ModeS; ModeSCountry = aircraft.ModeSCountry; MTOW = aircraft.MTOW; OperatorFlagCode = aircraft.OperatorFlagCode; OwnershipStatus = aircraft.OwnershipStatus; PictureUrl1 = aircraft.PictureUrl1; PictureUrl2 = aircraft.PictureUrl2; PictureUrl3 = aircraft.PictureUrl3; PopularName = aircraft.PopularName; PreviousID = aircraft.PreviousID; Registration = aircraft.Registration; RegisteredOwners = aircraft.RegisteredOwners; SerialNo = aircraft.SerialNo; Status = aircraft.Status; TotalHours = aircraft.TotalHours; Type = aircraft.Type; UserNotes = aircraft.UserNotes; UserTag = aircraft.UserTag; YearBuilt = aircraft.YearBuilt; UserString1 = aircraft.UserString1; UserString2 = aircraft.UserString2; UserString3 = aircraft.UserString3; UserString4 = aircraft.UserString4; UserString5 = aircraft.UserString5; UserBool1 = aircraft.UserBool1; UserBool2 = aircraft.UserBool2; UserBool3 = aircraft.UserBool3; UserBool4 = aircraft.UserBool4; UserBool5 = aircraft.UserBool5; UserInt1 = aircraft.UserInt1; UserInt2 = aircraft.UserInt2; UserInt3 = aircraft.UserInt3; UserInt4 = aircraft.UserInt4; UserInt5 = aircraft.UserInt5; }
public void BaseStationAircraft_Initialises_To_Known_State_And_Properties_Work() { var baseStationAircraft = new BaseStationAircraft(); TestUtilities.TestProperty(baseStationAircraft, r => r.AircraftClass, null, "Ab"); TestUtilities.TestProperty(baseStationAircraft, r => r.AircraftID, 0, 129); TestUtilities.TestProperty(baseStationAircraft, r => r.CofACategory, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.CofAExpiry, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.Country, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.CurrentRegDate, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.DeRegDate, null, "Nn"); TestUtilities.TestProperty(baseStationAircraft, r => r.Engines, null, "Xx"); TestUtilities.TestProperty(baseStationAircraft, r => r.FirstCreated, DateTime.MinValue, DateTime.Today); TestUtilities.TestProperty(baseStationAircraft, r => r.FirstRegDate, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.GenericName, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.ICAOTypeCode, null, "Uu"); TestUtilities.TestProperty(baseStationAircraft, r => r.InfoUrl, null, "Uu"); TestUtilities.TestProperty(baseStationAircraft, r => r.Interested, false); TestUtilities.TestProperty(baseStationAircraft, r => r.LastModified, DateTime.MinValue, DateTime.Today); TestUtilities.TestProperty(baseStationAircraft, r => r.Manufacturer, null, "Pp"); TestUtilities.TestProperty(baseStationAircraft, r => r.ModeS, null, "Ii"); TestUtilities.TestProperty(baseStationAircraft, r => r.ModeSCountry, null, "Ll"); TestUtilities.TestProperty(baseStationAircraft, r => r.MTOW, null, "Bb"); TestUtilities.TestProperty(baseStationAircraft, r => r.OperatorFlagCode, null, "Wx"); TestUtilities.TestProperty(baseStationAircraft, r => r.OwnershipStatus, null, "Ww"); TestUtilities.TestProperty(baseStationAircraft, r => r.PictureUrl1, null, "Uu"); TestUtilities.TestProperty(baseStationAircraft, r => r.PictureUrl2, null, "Uu"); TestUtilities.TestProperty(baseStationAircraft, r => r.PictureUrl3, null, "Uu"); TestUtilities.TestProperty(baseStationAircraft, r => r.PopularName, null, "Hg"); TestUtilities.TestProperty(baseStationAircraft, r => r.PreviousID, null, "Ds"); TestUtilities.TestProperty(baseStationAircraft, r => r.RegisteredOwners, null, "xZ"); TestUtilities.TestProperty(baseStationAircraft, r => r.Registration, null, "Vv"); TestUtilities.TestProperty(baseStationAircraft, r => r.SerialNo, null, "EWe"); TestUtilities.TestProperty(baseStationAircraft, r => r.Status, null, "St"); TestUtilities.TestProperty(baseStationAircraft, r => r.TotalHours, null, "Jjk"); TestUtilities.TestProperty(baseStationAircraft, r => r.Type, null, "Jjk"); TestUtilities.TestProperty(baseStationAircraft, r => r.UserNotes, null, "Jjk"); TestUtilities.TestProperty(baseStationAircraft, r => r.UserTag, null, "Abc"); TestUtilities.TestProperty(baseStationAircraft, r => r.YearBuilt, null, "Jjk"); }
public List<BaseStationFlight> GetFlightsForAircraft(BaseStationAircraft aircraft, SearchBaseStationCriteria criteria, int fromRow, int toRow, string sort1, bool sort1Ascending, string sort2, bool sort2Ascending) { return new List<BaseStationFlight>(); }
public void UpdateAircraft(BaseStationAircraft aircraft) { ; }
/// <summary> /// Copies the content of an IDataReader containing an aircraft's information into an object. /// </summary> /// <param name="reader"></param> /// <param name="ordinal"></param> /// <returns></returns> public static BaseStationAircraft DecodeFullAircraft(IDataReader reader, ref int ordinal) { BaseStationAircraft result = new BaseStationAircraft(); result.AircraftClass = Sql.GetString(reader, ordinal++); result.AircraftID = Sql.GetInt32(reader, ordinal++); result.Country = Sql.GetString(reader, ordinal++); result.DeRegDate = Sql.GetString(reader, ordinal++); result.Engines = Sql.GetString(reader, ordinal++); result.FirstCreated = Sql.GetDateTime(reader, ordinal++); result.GenericName = Sql.GetString(reader, ordinal++); result.ICAOTypeCode = Sql.GetString(reader, ordinal++); result.LastModified = Sql.GetDateTime(reader, ordinal++); result.Manufacturer = Sql.GetString(reader, ordinal++); result.ModeS = Sql.GetString(reader, ordinal++); result.ModeSCountry = Sql.GetString(reader, ordinal++); result.OperatorFlagCode = Sql.GetString(reader, ordinal++); result.OwnershipStatus = Sql.GetString(reader, ordinal++); result.PopularName = Sql.GetString(reader, ordinal++); result.PreviousID = Sql.GetString(reader, ordinal++); result.RegisteredOwners = Sql.GetString(reader, ordinal++); result.Registration = Sql.GetString(reader, ordinal++); result.SerialNo = Sql.GetString(reader, ordinal++); result.Status = Sql.GetString(reader, ordinal++); result.Type = Sql.GetString(reader, ordinal++); result.CofACategory = Sql.GetString(reader, ordinal++); result.CofAExpiry = Sql.GetString(reader, ordinal++); result.CurrentRegDate = Sql.GetString(reader, ordinal++); result.FirstRegDate = Sql.GetString(reader, ordinal++); result.InfoUrl = Sql.GetString(reader, ordinal++); result.Interested = Sql.GetBool(reader, ordinal++); result.MTOW = Sql.GetString(reader, ordinal++); result.PictureUrl1 = Sql.GetString(reader, ordinal++); result.PictureUrl2 = Sql.GetString(reader, ordinal++); result.PictureUrl3 = Sql.GetString(reader, ordinal++); result.TotalHours = Sql.GetString(reader, ordinal++); result.UserNotes = Sql.GetString(reader, ordinal++); result.UserTag = Sql.GetString(reader, ordinal++); result.YearBuilt = Sql.GetString(reader, ordinal++); return result; }
/// <summary> /// Updates the aircraft passed across with new values. /// </summary> /// <param name="connection"></param> /// <param name="transaction"></param> /// <param name="log"></param> /// <param name="aircraft"></param> public void Update(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationAircraft aircraft) { var preparedCommand = PrepareCommand(connection, transaction, "Update", _UpdateCommandText, 35); Sql.SetParameters(preparedCommand, aircraft.AircraftClass, aircraft.CofACategory, aircraft.CofAExpiry, aircraft.Country, aircraft.CurrentRegDate, aircraft.DeRegDate, aircraft.Engines, aircraft.FirstCreated, aircraft.FirstRegDate, aircraft.GenericName, aircraft.ICAOTypeCode, aircraft.InfoUrl, aircraft.Interested, aircraft.LastModified, aircraft.Manufacturer, aircraft.ModeS, aircraft.ModeSCountry, aircraft.MTOW, aircraft.OperatorFlagCode, aircraft.OwnershipStatus, aircraft.PictureUrl1, aircraft.PictureUrl2, aircraft.PictureUrl3, aircraft.PopularName, aircraft.PreviousID, aircraft.Registration, aircraft.RegisteredOwners, aircraft.SerialNo, aircraft.Status, aircraft.TotalHours, aircraft.Type, aircraft.UserNotes, aircraft.UserTag, aircraft.YearBuilt, aircraft.AircraftID); Sql.LogCommand(log, preparedCommand.Command); preparedCommand.Command.ExecuteNonQuery(); }
public void BaseStationDatabase_UpdateAircraftModeSCountry_Throws_If_Writes_Disabled() { var aircraft = new BaseStationAircraft() { ModeS = "X" }; aircraft.AircraftID = (int)AddAircraft(aircraft); aircraft.Registration = "C"; _Database.UpdateAircraftModeSCountry(aircraft.AircraftID, "X"); }
public void BaseStationDatabase_CreateDatabaseIfMissing_Creates_Aircraft_Trigger_To_Delete_Flights() { _Database.CreateDatabaseIfMissing(_CreateDatabaseFileName); _Database.FileName = _CreateDatabaseFileName; _Database.WriteSupportEnabled = true; var session = new BaseStationSession() { StartTime = DateTime.Now }; _Database.InsertSession(session); var aircraft = new BaseStationAircraft() { ModeS = "K" }; _Database.InsertAircraft(aircraft); var flight = new BaseStationFlight() { AircraftID = aircraft.AircraftID, SessionID = session.SessionID }; _Database.InsertFlight(flight); _Database.DeleteAircraft(aircraft); Assert.IsNull(_Database.GetFlightById(flight.FlightID)); Assert.AreEqual(session.SessionID, _Database.GetSessions()[0].SessionID); }
/// <summary> /// Creates a flight object. /// </summary> /// <param name="actual"></param> /// <returns></returns> private BaseStationFlight CreateFlight(BaseStationAircraft aircraft = null, string id = null) { var result = new BaseStationFlight() { Aircraft = new BaseStationAircraft() }; if(id != null) result.Callsign = id; if(aircraft != null) result.Aircraft = aircraft; if(result.Aircraft != null) result.AircraftID = result.Aircraft.AircraftID; return result; }
public void BaseStationAircraftList_MessageReceived_Looks_Up_Codeblock_Details() { var codeblock1 = new CodeBlock() { Country = "UK", IsMilitary = false, }; _StandingDataManager.Setup(m => m.FindCodeBlock("1")).Returns(codeblock1); var dbRecord1 = new BaseStationAircraft(); _BaseStationDatabase.Setup(m => m.GetAircraftByCode("1")).Returns(dbRecord1); dbRecord1.Country = "UNUSED"; dbRecord1.ModeSCountry = "UNUSED"; var codeBlock2 = new CodeBlock() { IsMilitary = true, }; _StandingDataManager.Setup(m => m.FindCodeBlock("2")).Returns(codeBlock2); _AircraftList.Start(); _BaseStationMessage.Icao24 = "1"; _Port30003Listener.Raise(m => m.Port30003MessageReceived += null, _BaseStationMessageEventArgs); _BaseStationMessage.Icao24 = "2"; _Port30003Listener.Raise(m => m.Port30003MessageReceived += null, _BaseStationMessageEventArgs); var aircraft1 = _AircraftList.FindAircraft(1); Assert.AreEqual("UK", aircraft1.Icao24Country); Assert.AreEqual(false, aircraft1.IsMilitary); var aircraft2 = _AircraftList.FindAircraft(2); Assert.AreEqual(true, aircraft2.IsMilitary); }
/// <summary> /// See interface docs. /// </summary> /// <param name="aircraft"></param> /// <param name="criteria"></param> /// <param name="fromRow"></param> /// <param name="toRow"></param> /// <param name="sort1"></param> /// <param name="sort1Ascending"></param> /// <param name="sort2"></param> /// <param name="sort2Ascending"></param> /// <returns></returns> public List<BaseStationFlight> GetFlightsForAircraft(BaseStationAircraft aircraft, SearchBaseStationCriteria criteria, int fromRow, int toRow, string sort1, bool sort1Ascending, string sort2, bool sort2Ascending) { if(criteria == null) throw new ArgumentNullException("criteria"); FlightsTable.NormaliseCriteria(criteria); List<BaseStationFlight> result = new List<BaseStationFlight>(); if(aircraft != null) { lock(_ConnectionLock) { OpenConnection(); if(_Connection != null) result = _FlightTable.GetForAircraft(_Connection, null, _DatabaseLog, aircraft, criteria, fromRow, toRow, sort1, sort1Ascending, sort2, sort2Ascending); } } return result; }
/// <summary> /// See interface docs. /// </summary> /// <param name="aircraft"></param> /// <param name="criteria"></param> /// <returns></returns> public int GetCountOfFlightsForAircraft(BaseStationAircraft aircraft, SearchBaseStationCriteria criteria) { if(criteria == null) throw new ArgumentNullException("criteria"); FlightsTable.NormaliseCriteria(criteria); int result = 0; if(aircraft != null) { lock(_ConnectionLock) { OpenConnection(); if(_Connection != null) result = _FlightTable.GetCountForAircraft(_Connection, null, _DatabaseLog, aircraft, criteria); } } return result; }
/// <summary> /// See interface docs. /// </summary> /// <param name="aircraft"></param> public void DeleteAircraft(BaseStationAircraft aircraft) { if(!WriteSupportEnabled) throw new InvalidOperationException("You cannot delete aircraft when write support is disabled"); lock(_ConnectionLock) { OpenConnection(); if(_Connection != null) _AircraftTable.Delete(_Connection, _TransactionHelper.Transaction, _DatabaseLog, aircraft); } }
/// <summary> /// See interface docs. /// </summary> /// <param name="aircraft"></param> public void UpdateAircraft(BaseStationAircraft aircraft) { if(!WriteSupportEnabled) throw new InvalidOperationException("You cannot update aircraft when write support is disabled"); aircraft.FirstCreated = SQLiteDateHelper.Truncate(aircraft.FirstCreated); aircraft.LastModified = SQLiteDateHelper.Truncate(aircraft.LastModified); lock(_ConnectionLock) { OpenConnection(); if(_Connection != null) _AircraftTable.Update(_Connection, _TransactionHelper.Transaction, _DatabaseLog, aircraft); } }
/// <summary> /// Fetches the aircraft record from the database for the ICAO24 code passed across. If there is no /// record for the ICAO24 code then one is created. /// </summary> /// <param name="localNow"></param> /// <param name="icao24"></param> /// <returns></returns> private BaseStationAircraft FetchOrCreateAircraft(DateTime now, string icao24) { var result = _Database.GetAircraftByCode(icao24); if(result == null) { var codeBlock = _StandingDataManager.FindCodeBlock(icao24); result = new BaseStationAircraft() { AircraftID = 0, ModeS = icao24, FirstCreated = now, LastModified = now, ModeSCountry = codeBlock == null ? null : codeBlock.Country, }; _Database.InsertAircraft(result); } return result; }
private long AddAircraft(BaseStationAircraft aircraft) { long result = 0; using(var connection = new SQLiteConnection(_ConnectionStringBuilder.ConnectionString)) { connection.Open(); using(var command = connection.CreateCommand()) { var fieldNames = new StringBuilder(); var parameters = new StringBuilder(); foreach(var property in typeof(BaseStationAircraft).GetProperties()) { var fieldName = property.Name; if(fieldName == "AircraftID") continue; if(fieldNames.Length > 0) fieldNames.Append(','); if(parameters.Length > 0) parameters.Append(','); fieldNames.AppendFormat("[{0}]", fieldName); parameters.Append('?'); var parameter = command.CreateParameter(); parameter.Value = property.GetValue(aircraft, null); command.Parameters.Add(parameter); } command.CommandText = String.Format("INSERT INTO [Aircraft] ({0}) VALUES ({1}); SELECT last_insert_rowid();", fieldNames, parameters); result = (long)command.ExecuteScalar(); aircraft.AircraftID = (int)result; } } return result; }
public void TestInitialise() { _BackgroundException = null; _ClassFactorySnapshot = Factory.TakeSnapshot(); _RuntimeEnvironment = TestUtilities.CreateMockSingleton<IRuntimeEnvironment>(); _RuntimeEnvironment.Setup(r => r.IsTest).Returns(true); _ConfigurationStorage = TestUtilities.CreateMockSingleton<IConfigurationStorage>(); _Configuration = new Configuration(); _ConfigurationStorage.Setup(m => m.Load()).Returns(_Configuration); _AircraftPictureManager = TestUtilities.CreateMockSingleton<IAircraftPictureManager>(); _HeartbeatService = TestUtilities.CreateMockSingleton<IHeartbeatService>(); _AutoConfigPictureFolderCache = TestUtilities.CreateMockSingleton<IAutoConfigPictureFolderCache>(); _PictureDirectoryCache = new Mock<IDirectoryCache>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _AutoConfigPictureFolderCache.Setup(a => a.DirectoryCache).Returns(_PictureDirectoryCache.Object); _AircraftList = Factory.Singleton.Resolve<IBaseStationAircraftList>(); _AircraftList.ExceptionCaught += AircraftListExceptionCaughtHandler; _Provider = new Mock<IBaseStationAircraftListProvider>().SetupAllProperties(); _Provider.Setup(m => m.UtcNow).Returns(DateTime.UtcNow); _Port30003Listener = new Mock<IListener>().SetupAllProperties(); _BaseStationDatabase = new Mock<IBaseStationDatabase>().SetupAllProperties(); _StandingDataManager = TestUtilities.CreateMockSingleton<IStandingDataManager>(); _AircraftList.Provider = _Provider.Object; _AircraftList.Listener = _Port30003Listener.Object; _AircraftList.BaseStationDatabase = _BaseStationDatabase.Object; _AircraftList.StandingDataManager = _StandingDataManager.Object; _BaseStationMessage = new BaseStationMessage(); _BaseStationMessage.MessageType = BaseStationMessageType.Transmission; _BaseStationMessage.Icao24 = "4008F6"; _BaseStationMessageEventArgs = new BaseStationMessageEventArgs(_BaseStationMessage); _BaseStationAircraft = new BaseStationAircraft(); _BaseStationDatabase.Setup(m => m.GetAircraftByCode("4008F6")).Returns(_BaseStationAircraft); _Heathrow = new Airport() { IcaoCode = "EGLL", IataCode = "LHR", Name = "Heathrow", Country = "UK", }; _JohnFKennedy = new Airport() { IcaoCode = "KJFK", IataCode = "JFK", Country = "USA", }; _Helsinki = new Airport() { IataCode = "HEL", }; _Boston = new Airport() { IcaoCode = "KBOS", }; _Route = new Route() { From = _Heathrow, To = _JohnFKennedy, Stopovers = { _Helsinki }, }; _ExceptionCaughtEvent = new EventRecorder<EventArgs<Exception>>(); _CountChangedEvent = new EventRecorder<EventArgs>(); }
public void BaseStationDatabase_CreateDatabaseIfMissing_Creates_Flights_Table() { _Database.CreateDatabaseIfMissing(_CreateDatabaseFileName); _Database.FileName = _CreateDatabaseFileName; var aircraft = new BaseStationAircraft() { ModeS = "1" }; var session = new BaseStationSession() { StartTime = DateTime.Now }; _Database.WriteSupportEnabled = true; _Database.InsertSession(session); _Database.InsertAircraft(aircraft); _Database.InsertFlight(new BaseStationFlight() { AircraftID = aircraft.AircraftID, SessionID = session.SessionID }); }
public void Plugin_Aircraft_Record_Not_Touched_If_Aircraft_Record_Already_Exists_For_Transmitting_Aircraft() { SetEnabledOption(true); BaseStationAircraft aircraft = new BaseStationAircraft(); _BaseStationDatabase.Setup(d => d.GetAircraftByCode("X")).Returns(aircraft); _Plugin.Startup(_StartupParameters); var message = new BaseStationMessage() { AircraftId = 99, Icao24 = "X" }; _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(message)); _BaseStationDatabase.Verify(d => d.InsertAircraft(It.IsAny<BaseStationAircraft>()), Times.Never()); _BaseStationDatabase.Verify(d => d.UpdateAircraft(It.IsAny<BaseStationAircraft>()), Times.Never()); }
private static void AssertAircraftAreEqual(BaseStationAircraft expected, BaseStationAircraft actual, long id = -1L) { Assert.AreEqual(id == -1L ? expected.AircraftID : (int)id, actual.AircraftID); Assert.AreEqual(expected.AircraftClass, actual.AircraftClass); Assert.AreEqual(expected.Country, actual.Country); Assert.AreEqual(expected.DeRegDate, actual.DeRegDate); Assert.AreEqual(expected.Engines, actual.Engines); Assert.AreEqual(expected.FirstCreated, actual.FirstCreated); Assert.AreEqual(expected.GenericName, actual.GenericName); Assert.AreEqual(expected.ICAOTypeCode, actual.ICAOTypeCode); Assert.AreEqual(expected.LastModified, actual.LastModified); Assert.AreEqual(expected.Manufacturer, actual.Manufacturer); Assert.AreEqual(expected.ModeS, actual.ModeS); Assert.AreEqual(expected.ModeSCountry, actual.ModeSCountry); Assert.AreEqual(expected.OperatorFlagCode, actual.OperatorFlagCode); Assert.AreEqual(expected.OwnershipStatus, actual.OwnershipStatus); Assert.AreEqual(expected.PopularName, actual.PopularName); Assert.AreEqual(expected.PreviousID, actual.PreviousID); Assert.AreEqual(expected.RegisteredOwners, actual.RegisteredOwners); Assert.AreEqual(expected.Registration, actual.Registration); Assert.AreEqual(expected.SerialNo, actual.SerialNo); Assert.AreEqual(expected.Status, actual.Status); Assert.AreEqual(expected.Type, actual.Type); Assert.AreEqual(expected.CofACategory, actual.CofACategory); Assert.AreEqual(expected.CofAExpiry, actual.CofAExpiry); Assert.AreEqual(expected.CurrentRegDate, actual.CurrentRegDate); Assert.AreEqual(expected.FirstRegDate, actual.FirstRegDate); Assert.AreEqual(expected.InfoUrl, actual.InfoUrl); Assert.AreEqual(expected.Interested, actual.Interested); Assert.AreEqual(expected.MTOW, actual.MTOW); Assert.AreEqual(expected.PictureUrl1, actual.PictureUrl1); Assert.AreEqual(expected.PictureUrl2, actual.PictureUrl2); Assert.AreEqual(expected.PictureUrl3, actual.PictureUrl3); Assert.AreEqual(expected.TotalHours, actual.TotalHours); Assert.AreEqual(expected.UserNotes, actual.UserNotes); Assert.AreEqual(expected.UserTag, actual.UserTag); Assert.AreEqual(expected.YearBuilt, actual.YearBuilt); }
public void Plugin_Flight_Record_Still_Inserted_If_Aircraft_Record_Already_Exists_For_Transmitting_Aircraft() { SetEnabledOption(true); BaseStationFlight flight = null; BaseStationAircraft aircraft = new BaseStationAircraft() { AircraftID = 5832, ModeS = "X" }; _BaseStationDatabase.Setup(d => d.GetAircraftByCode("X")).Returns(aircraft); _BaseStationDatabase.Setup(d => d.InsertFlight(It.IsAny<BaseStationFlight>())).Callback((BaseStationFlight f) => { flight = f; }); _Plugin.Startup(_StartupParameters); var message = new BaseStationMessage() { AircraftId = 99, Icao24 = "X", MessageType = BaseStationMessageType.Transmission, TransmissionType = BaseStationTransmissionType.AirToAir }; _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(message)); _BaseStationDatabase.Verify(d => d.InsertFlight(It.IsAny<BaseStationFlight>()), Times.Once()); Assert.AreEqual(5832, flight.AircraftID); }
/// <summary> /// Inserts a record into the database and returns its ID. /// </summary> /// <param name="connection"></param> /// <param name="transaction"></param> /// <param name="log"></param> /// <param name="aircraft"></param> /// <returns></returns> public int Insert(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationAircraft aircraft) { var preparedCommand = PrepareInsert(connection, transaction, "Insert", "AircraftID", "AircraftClass", "CofACategory", "CofAExpiry", "Country", "CurrentRegDate", "DeRegDate", "Engines", "FirstCreated", "FirstRegDate", "GenericName", "ICAOTypeCode", "InfoUrl", "Interested", "LastModified", "Manufacturer", "ModeS", "ModeSCountry", "MTOW", "OperatorFlagCode", "OwnershipStatus", "PictureUrl1", "PictureUrl2", "PictureUrl3", "PopularName", "PreviousID", "Registration", "RegisteredOwners", "SerialNo", "Status", "TotalHours", "Type", "UserNotes", "UserTag", "YearBuilt"); return (int)Sql.ExecuteInsert(preparedCommand, log, aircraft.AircraftClass, aircraft.CofACategory, aircraft.CofAExpiry, aircraft.Country, aircraft.CurrentRegDate, aircraft.DeRegDate, aircraft.Engines, aircraft.FirstCreated, aircraft.FirstRegDate, aircraft.GenericName, aircraft.ICAOTypeCode, aircraft.InfoUrl, aircraft.Interested, aircraft.LastModified, aircraft.Manufacturer, aircraft.ModeS, aircraft.ModeSCountry, aircraft.MTOW, aircraft.OperatorFlagCode, aircraft.OwnershipStatus, aircraft.PictureUrl1, aircraft.PictureUrl2, aircraft.PictureUrl3, aircraft.PopularName, aircraft.PreviousID, aircraft.Registration, aircraft.RegisteredOwners, aircraft.SerialNo, aircraft.Status, aircraft.TotalHours, aircraft.Type, aircraft.UserNotes, aircraft.UserTag, aircraft.YearBuilt); }
public void Plugin_Aircraft_Database_Not_Repeatedly_Polled_For_Same_Aircraft() { SetEnabledOption(true); BaseStationAircraft aircraft = new BaseStationAircraft(); _BaseStationDatabase.Setup(d => d.GetAircraftByCode("X")).Returns(aircraft); _Plugin.Startup(_StartupParameters); var messageX = new BaseStationMessage() { AircraftId = 99, Icao24 = "X", MessageType = BaseStationMessageType.Transmission, TransmissionType = BaseStationTransmissionType.AirToAir }; var messageY = new BaseStationMessage() { AircraftId = 42, Icao24 = "Y", MessageType = BaseStationMessageType.Transmission, TransmissionType = BaseStationTransmissionType.AirToAir }; _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(messageX)); _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(messageX)); _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(messageY)); _BaseStationDatabase.Verify(d => d.GetAircraftByCode("X"), Times.Once()); _BaseStationDatabase.Verify(d => d.GetAircraftByCode("Y"), Times.Once()); }
/// <summary> /// Deletes the aircraft passed across. /// </summary> /// <param name="connection"></param> /// <param name="transaction"></param> /// <param name="log"></param> /// <param name="aircraft"></param> public void Delete(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationAircraft aircraft) { var preparedCommand = PrepareCommand(connection, transaction, "Delete", _DeleteCommandText, 1); Sql.SetParameters(preparedCommand, aircraft.AircraftID); Sql.LogCommand(log, preparedCommand.Command); preparedCommand.Command.ExecuteNonQuery(); }
public void Plugin_Flight_Record_Not_Repeatedly_Inserted_For_Same_Aircraft() { SetEnabledOption(true); BaseStationAircraft aircraft = new BaseStationAircraft() { AircraftID = 5832, ModeS = "X" }; _BaseStationDatabase.Setup(d => d.GetAircraftByCode("X")).Returns(aircraft); _Plugin.Startup(_StartupParameters); var message = new BaseStationMessage() { AircraftId = 99, Icao24 = "X", MessageType = BaseStationMessageType.Transmission, TransmissionType = BaseStationTransmissionType.AirToAir }; _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(message)); _Listener.Raise(r => r.Port30003MessageReceived += null, new BaseStationMessageEventArgs(message)); _BaseStationDatabase.Verify(d => d.InsertFlight(It.IsAny<BaseStationFlight>()), Times.Once()); _BaseStationDatabase.Verify(d => d.UpdateFlight(It.IsAny<BaseStationFlight>()), Times.Never()); }
public void InsertAircraft(BaseStationAircraft aircraft) { ; }
public void BaseStationDatabase_DeleteAircraft_Throws_If_Writes_Disabled() { var aircraft = new BaseStationAircraft() { ModeS = "X" }; aircraft.AircraftID = (int)AddAircraft(aircraft); _Database.DeleteAircraft(aircraft); }
public void DeleteAircraft(BaseStationAircraft aircraft) { ; }
/// <summary> /// Reads actual details from a spreadsheet, assuming that the fields are in alphabetical order from the first ordinal passed across. /// </summary> /// <param name="expected"></param> /// <param name="firstOrdinal"></param> /// <param name="copyIntoAircraft"></param> /// <returns></returns> /// <remarks> /// The fields, in ascending order of ordinal, are: /// AircraftClass, Country, DeRegDate, Engines, FirstCreated, GenericName, ICAOTypeCode, LastModified, Manufacturer, ModeS, ModeSCountry, /// OperatorFlagCode, OwnershipStatus, PopularName, PreviousID, RegisteredOwners, Registration, SerialNo, Status, Type, CofACategory, CofAExpiry /// CurrentRegDate, FirstRegDate, InfoUrl, Interested, MTOW, PictureUrl1, PictureUrl2, PictureUrl3, TotalHours, UserNotes, UserTag and YearBuilt. /// </remarks> private BaseStationAircraft LoadAircraftFromSpreadsheet(ExcelWorksheetData worksheet, int firstOrdinal = 0, BaseStationAircraft copyIntoAircraft = null) { var result = copyIntoAircraft == null ? new BaseStationAircraft() : copyIntoAircraft; int ordinal = firstOrdinal; result.AircraftClass = worksheet.EString(ordinal++); result.Country = worksheet.EString(ordinal++); result.DeRegDate = worksheet.EString(ordinal++); result.Engines = worksheet.EString(ordinal++); result.FirstCreated = worksheet.DateTime(ordinal++); result.GenericName = worksheet.EString(ordinal++); result.ICAOTypeCode = worksheet.EString(ordinal++); result.LastModified = worksheet.DateTime(ordinal++); result.Manufacturer = worksheet.EString(ordinal++); result.ModeS = worksheet.EString(ordinal++); result.ModeSCountry = worksheet.EString(ordinal++); result.OperatorFlagCode = worksheet.EString(ordinal++); result.OwnershipStatus = worksheet.EString(ordinal++); result.PopularName = worksheet.EString(ordinal++); result.PreviousID = worksheet.EString(ordinal++); result.RegisteredOwners = worksheet.EString(ordinal++); result.Registration = worksheet.EString(ordinal++); result.SerialNo = worksheet.EString(ordinal++); result.Status = worksheet.EString(ordinal++); result.Type = worksheet.EString(ordinal++); result.CofACategory = worksheet.EString(ordinal++); result.CofAExpiry = worksheet.EString(ordinal++); result.CurrentRegDate = worksheet.EString(ordinal++); result.FirstRegDate = worksheet.EString(ordinal++); result.InfoUrl = worksheet.EString(ordinal++); result.Interested = worksheet.Bool(ordinal++); result.MTOW = worksheet.EString(ordinal++); result.PictureUrl1 = worksheet.EString(ordinal++); result.PictureUrl2 = worksheet.EString(ordinal++); result.PictureUrl3 = worksheet.EString(ordinal++); result.TotalHours = worksheet.EString(ordinal++); result.UserNotes = worksheet.EString(ordinal++); result.UserTag = worksheet.EString(ordinal++); result.YearBuilt = worksheet.EString(ordinal++); return result; }
public int GetCountOfFlightsForAircraft(BaseStationAircraft aircraft, SearchBaseStationCriteria criteria) { return 0; }
public void BaseStationDatabase_GetFlightById_Returns_Flight_Object_For_Record_Identifier() { var worksheet = new ExcelWorksheetData(TestContext); var aircraft = new BaseStationAircraft() { ModeS = "A" }; aircraft.AircraftID = (int)AddAircraft(aircraft); var mockFlight = LoadFlightFromSpreadsheet(worksheet); mockFlight.SessionID = (int)AddSession(new BaseStationSession() { StartTime = DateTime.Now }); mockFlight.Aircraft = aircraft; mockFlight.AircraftID = aircraft.AircraftID; var id = (int)AddFlight(mockFlight); var flight = _Database.GetFlightById(id); Assert.AreNotSame(flight, mockFlight); AssertFlightsAreEqual(mockFlight, flight, false, aircraft.AircraftID); }