public void Given_TheDataIsCorrect_When_ParseIsCalled_Then_TheDataIsParsedAsExpected() { string sourceName = "This is the source name"; var bytes = GetUniverseDiscoveryPacketFramingLayer(sourceName); var framingLayer = UniverseDiscoveryPacketFramingLayer.Parse(bytes.ToArray()); Assert.Equal(FramingLayerVector.VECTOR_E131_EXTENDED_DISCOVERY, framingLayer.Vector); Assert.Equal(sourceName, framingLayer.SourceName); }
public void Given_TheVectorIsIncorrect_When_ParseIsCalled_Then_NullIsReturned() { List <byte> bytes = new List <byte>(); bytes.AddRange(new byte[] { 0x7 << 4, UniverseDiscoveryPacketFramingLayer.Length }); // flags and length bytes.AddRange(new byte[] { 0, 0, 0, (byte)42 }); // Vector string sourceName = "This is the source name"; bytes.AddRange(Encoding.UTF8.GetBytes(sourceName)); bytes.AddRange(Enumerable.Repeat((byte)0, 64 - sourceName.Length)); bytes.AddRange(new byte[] { 0, 0, 0, 0 }); // reserved Assert.Null(UniverseDiscoveryPacketFramingLayer.Parse(bytes.ToArray())); }