public async void TestRecieveSingleTelexAcarsMessage() { var acarsClient = new AcarsClient( CALLSIGN, LOGON_SECRET, false, GetMockedHttpClient(HttpStatusCode.OK, ACARS_MESSAGES_SINGLE_TELEX) ); // ACT AcarsMessage[] result = await acarsClient.GetPendingMessages().ConfigureAwait(false); // ASSERT Assert.NotNull(result); Assert.True(result.Length == 1); Assert.Equal("SWSM", result[0].From); Assert.Equal(AcarsClient.MessageType.Telex, result[0].Type); Assert.Equal(CALLSIGN, result[0].To); Assert.Equal("TEST", result[0].Data); }
public async void TestRecieveAcarsMessageServerError() { var acarsClient = new AcarsClient( CALLSIGN, LOGON_SECRET, false, GetMockedHttpClient(HttpStatusCode.InternalServerError, "") ); // ACT try { AcarsMessage[] result = await acarsClient.GetPendingMessages().ConfigureAwait(false); } catch (Exception ex) { // ASSERT Assert.NotNull(ex); Assert.Equal("Error communicating with Hoppie server over HTTP: Response status code does not indicate success: 500 (Internal Server Error).", ex.Message); } }
public async void TestRecieveSingleCpdlcAcarsMessage() { var acarsClient = new AcarsClient( CALLSIGN, LOGON_SECRET, false, GetMockedHttpClient(HttpStatusCode.OK, ACARS_MESSAGES_SINGLE_CPDLC) ); // ACT AcarsMessage[] result = await acarsClient.GetPendingMessages().ConfigureAwait(false); // ASSERT Assert.NotNull(result); Assert.True(result.Length == 1); Assert.Equal("SWSM", result[0].From); Assert.Equal(AcarsClient.MessageType.CPDLC, result[0].Type); Assert.Equal(CALLSIGN, result[0].To); Assert.Equal("/data2/14//R/AT @ELTOK@ EXPECT @300K", result[0].Data); }
public async void TestRecieveMultipleMixedAcarsMessages() { var acarsClient = new AcarsClient( CALLSIGN, LOGON_SECRET, false, GetMockedHttpClient(HttpStatusCode.OK, ACARS_MESSAGES_MULTIPLE_MIXED) ); // ACT AcarsMessage[] result = await acarsClient.GetPendingMessages().ConfigureAwait(false); // ASSERT Assert.NotNull(result); Assert.True(result.Length == 9); Assert.True(result[0].RecievedAt < DateTime.Now); Assert.Equal("SWSM", result[0].From); Assert.Equal(AcarsClient.MessageType.CPDLC, result[0].Type); Assert.Equal(CALLSIGN, result[0].To); Assert.Equal("/data2/14//R/AT @ELTOK@ EXPECT @300K", result[0].Data); Assert.IsType <CpdlcAcarsMessage>(result[4]); CpdlcAcarsMessage cpdlcMessage = (CpdlcAcarsMessage)result[4]; Assert.True(cpdlcMessage.RecievedAt < DateTime.Now); Assert.Equal("SWSM", cpdlcMessage.From); Assert.Equal(AcarsClient.MessageType.CPDLC, cpdlcMessage.Type); Assert.Equal(CALLSIGN, cpdlcMessage.To); Assert.Equal("/data2/10/9/NE/LOGON ACCEPTED", cpdlcMessage.Data); Assert.Equal("LOGON ACCEPTED", cpdlcMessage.Message); Assert.Equal(10, cpdlcMessage.MessageCount); Assert.Equal(CpdlcAcarsMessage.ResponseAttribute.UPLINK_NOT_ENABLED, cpdlcMessage.ResponseType); Assert.True(result[3].RecievedAt < DateTime.Now); Assert.Equal("SWSM", result[3].From); Assert.Equal(AcarsClient.MessageType.Telex, result[3].Type); Assert.Equal(CALLSIGN, result[3].To); Assert.Equal("TEST", result[3].Data); }