public void Test_Create_TelemetryFormatException_IncorrectValue() { var receiver = new cStringReceiver("name", null, null); var rawTele = "[1604614491:015:cheese]"; var ex = Assert.Throws <TelemetryFormatException>(() => receiver.DecodeFrame(Encoding.UTF8.GetBytes(rawTele))); Assert.StartsWith("Telemetry Value Encoding incorrect,", ex.Message); }
public void Test_Create_TelemetryFormatException_IncorrectTimestamp() { var receiver = new cStringReceiver("name", null, null); var rawTele = "[notatimestamp:01:-152.000000]"; var ex = Assert.Throws <TelemetryFormatException>(() => receiver.DecodeFrame(Encoding.UTF8.GetBytes(rawTele))); Assert.StartsWith("Timestamp Encoding incorrect", ex.Message); }
public void Test_Create_Negative() { var receiver = new cStringReceiver("name", null, null); Int64 unixTimeStamp = 1604614491; UInt16 teleType = 01; float teleValue = -152.000000f; var rawTele = BuildTeleString(unixTimeStamp, teleType, teleValue); var actualTele = receiver.DecodeFrame(Encoding.UTF8.GetBytes(rawTele)); var expectedTele = GetExpected(unixTimeStamp, teleType, teleValue); Assert.Equal(expectedTele.ToString(), actualTele.ToString()); }
public void Test_Create_Max() { var receiver = new cStringReceiver("name", null, null); Int64 unixTimeStamp = 253402300799; // Max value for FromUnixTimeSeconds UInt16 teleType = UInt16.MaxValue; float teleValue = float.MaxValue; var rawTele = BuildTeleString(unixTimeStamp, teleType, teleValue); var actualTele = receiver.DecodeFrame(Encoding.UTF8.GetBytes(rawTele)); var expectedTele = GetExpected(unixTimeStamp, teleType, teleValue); Assert.Equal(expectedTele.ToString(), actualTele.ToString()); }
public void Test_Create_TelemetryFormatException_NumParts() { var receiver = new cStringReceiver("name", null, null); Int64 unixTimeStamp = 1604614491; UInt16 teleType = 01; float teleValue = -152.000000f; var rawTele = BuildTeleString(unixTimeStamp, teleType, teleValue); var rawTeleMissingPart = rawTele.Remove(1, 11); var ex = Assert.Throws <TelemetryFormatException>(() => receiver.DecodeFrame(Encoding.UTF8.GetBytes(rawTeleMissingPart))); Assert.StartsWith("String Encoding incorrect, expected", ex.Message); }
public void Test_Create_TelemetryFormatException_Brackets() { var receiver = new cStringReceiver("name", null, null); Int64 unixTimeStamp = 1604614491; UInt16 teleType = 01; float teleValue = -152.000000f; var rawTele = BuildTeleString(unixTimeStamp, teleType, teleValue); var rawTeleWithoutFirstBracket = rawTele.Substring(1, rawTele.Length - 1); var ex = Assert.Throws <TelemetryFormatException>(() => receiver.DecodeFrame(Encoding.UTF8.GetBytes(rawTeleWithoutFirstBracket))); Assert.StartsWith("String Encoding missing opening or closing brackets:", ex.Message); }