public void BaseStationMessageTranslator_Translate_Parses_Transmission_Types_Correctly() { foreach(BaseStationTransmissionType transmissionType in Enum.GetValues(typeof(BaseStationTransmissionType))) { if(transmissionType == BaseStationTransmissionType.None) continue; string typeText = BaseStationMessageHelper.ConvertToString(transmissionType); BaseStationMessage message = _Implementation.Translate(String.Format("MSG,{0},5,2056,7404F2,11267,2008/11/28,23:48:18.611,2008/11/28,23:53:19.161,,,,,,,,,,,,", typeText)); Assert.AreEqual(transmissionType, message.TransmissionType, transmissionType.ToString()); } }
public void BaseStationMessageTranslator_Translate_Parses_Message_Types_Correctly() { foreach(BaseStationMessageType messageType in Enum.GetValues(typeof(BaseStationMessageType))) { if(messageType == BaseStationMessageType.Unknown) continue; string messageTypeText = BaseStationMessageHelper.ConvertToString(messageType); string text = String.Format("{0},1,5,2056,7404F2,11267,2008/11/28,23:48:18.611,2008/11/28,23:53:19.161,,,,,,,,,,,,", messageTypeText); BaseStationMessage message = _Implementation.Translate(text); Assert.AreEqual(messageType, message.MessageType, messageType.ToString()); } }
public void BaseStationMessageTranslator_Translate_Ignores_TransmissionType_For_All_NonTransmission_Messages() { foreach(BaseStationMessageType messageType in Enum.GetValues(typeof(BaseStationMessageType))) { if(messageType == BaseStationMessageType.Unknown) continue; foreach(BaseStationTransmissionType transmissionType in Enum.GetValues(typeof(BaseStationTransmissionType))) { if(transmissionType == BaseStationTransmissionType.None) continue; string text = String.Format("{0},{1},5,2056,7404F2,11267,2008/11/28,23:48:18.611,2008/11/28,23:53:19.161,,,,,,,,,,,,", BaseStationMessageHelper.ConvertToString(messageType), BaseStationMessageHelper.ConvertToString(transmissionType)); string errorText = String.Format("{0} and {1}", messageType, transmissionType); BaseStationMessage message = _Implementation.Translate(text); if(messageType == BaseStationMessageType.Transmission) Assert.AreEqual(transmissionType, message.TransmissionType, errorText); else Assert.AreEqual(BaseStationTransmissionType.None, message.TransmissionType, errorText); } } }
public void BaseStationMessageTranslator_Translate_Only_Translate_Status_Codes_For_Status_Messages() { foreach(BaseStationMessageType messageType in Enum.GetValues(typeof(BaseStationMessageType))) { if(messageType == BaseStationMessageType.Unknown) continue; foreach(BaseStationStatusCode statusCode in Enum.GetValues(typeof(BaseStationStatusCode))) { if(statusCode == BaseStationStatusCode.None) continue; string text = String.Format("{0},1,5,2056,7404F2,11267,2008/11/28,23:48:18.611,2008/11/28,23:53:19.161,{1},,,,,,,,,,,", BaseStationMessageHelper.ConvertToString(messageType), BaseStationMessageHelper.ConvertToString(statusCode)); string errorText = String.Format("{0} and {1}", messageType, statusCode); BaseStationMessage message = _Implementation.Translate(text); if(messageType == BaseStationMessageType.StatusChange) Assert.AreEqual(statusCode, message.StatusCode, errorText); else Assert.AreEqual(BaseStationMessageHelper.ConvertToString(statusCode), message.Callsign, errorText); } } }
public void BaseStationMessageHelperTests_ConvertToString_BaseStationStatusCode_Converts_All_Types_Correctly() { foreach (BaseStationStatusCode statusCode in Enum.GetValues(typeof(BaseStationStatusCode))) { string text = BaseStationMessageHelper.ConvertToString(statusCode); switch (statusCode) { case BaseStationStatusCode.Delete: Assert.AreEqual("AD", text); break; case BaseStationStatusCode.None: Assert.AreEqual("", text); break; case BaseStationStatusCode.OK: Assert.AreEqual("OK", text); break; case BaseStationStatusCode.PositionLost: Assert.AreEqual("PL", text); break; case BaseStationStatusCode.Remove: Assert.AreEqual("RM", text); break; case BaseStationStatusCode.SignalLost: Assert.AreEqual("SL", text); break; default: throw new NotImplementedException(); } } }
public void BaseStationMessageTranslator_Translate_Parses_Status_Codes_Correctly() { foreach (BaseStationStatusCode statusCode in Enum.GetValues(typeof(BaseStationStatusCode))) { if (statusCode == BaseStationStatusCode.None) { continue; } string text = String.Format("STA,1,5,2056,7404F2,11267,2008/11/28,23:48:18.611,2008/11/28,23:53:19.161,{0},,,,,,,,,,,", BaseStationMessageHelper.ConvertToString(statusCode)); BaseStationMessage message = _Implementation.Translate(text, 123); Assert.AreEqual(statusCode, message.StatusCode, statusCode.ToString()); } }