public void TestCreationAndParsing(UInt16 universeID, string sourceName, byte sequenceID, byte priority)
        {
            Guid guid = Guid.NewGuid();

            Random random = new Random();
            int    length = random.Next(1, 512);

            byte[] data = new byte[length];

            for (int i = 0; i < length; i++)
            {
                data[i] = (byte)random.Next(0, 255);
            }

            SACNPacket packet = new SACNPacket(universeID, sourceName, guid, sequenceID, data, priority);
            SACNPacket parsed = SACNPacket.Parse(packet.ToArray());

            Assert.AreEqual(universeID, parsed.UniverseID);
            Assert.AreEqual(sourceName, parsed.SourceName);
            Assert.AreEqual(sequenceID, parsed.SequenceID);
            Assert.AreEqual(priority, parsed.RootLayer.FramingLayer.Priority);
            Assert.AreEqual(data.Length, parsed.Data.Length);
            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i], parsed.Data[i]);
            }
        }
Beispiel #2
0
 private static void Listener_OnPacket(object sender, SACNPacket e)
 {
     Console.WriteLine("Packet from " + e.SourceName);
     Console.WriteLine("\tUniverseID = " + e.UniverseID);
     Console.WriteLine("\tSequenceID = " + e.SequenceID);
     Console.WriteLine("\tData = " + string.Join(",", e.Data));
 }
        public void EncodeParse_UniverseIDIsCorrect(UInt16 universeID)
        {
            SACNPacket sourcePacket = new SACNPacket(universeID, "SourceName", new Guid(), 1, new byte[512], 1);

            byte[] packetData = sourcePacket.ToArray();

            SACNPacket parsedPacket = SACNPacket.Parse(packetData);

            Assert.Equal(universeID, parsedPacket.UniverseID);
        }
        public void EncodeParse_SourceNameIsCorrect(string sourceName)
        {
            SACNPacket sourcePacket = new SACNPacket(1, sourceName, new Guid(), 1, new byte[512], 1);

            byte[] packetData = sourcePacket.ToArray();

            SACNPacket parsedPacket = SACNPacket.Parse(packetData);

            Assert.Equal(sourceName, parsedPacket.SourceName);
        }
        public void EncodeParse_PriorityIsCorrect(byte priority)
        {
            SACNPacket sourcePacket = new SACNPacket(1, "SourceName", new Guid(), 1, new byte[512], priority);

            byte[] packetData = sourcePacket.ToArray();

            SACNPacket parsedPacket = SACNPacket.Parse(packetData);

            Assert.Equal(priority, parsedPacket.RootLayer.FramingLayer.Priority);
        }
        public void EncodeParse_SequenceIDIsCorrect(byte sequenceID)
        {
            SACNPacket sourcePacket = new SACNPacket(1, "SourceName", new Guid(), sequenceID, new byte[512], 1);

            byte[] packetData = sourcePacket.ToArray();

            SACNPacket parsedPacket = SACNPacket.Parse(packetData);

            Assert.Equal(sequenceID, parsedPacket.SequenceID);
        }
        public void EncodeParse_GuidIsCorrect(int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k)
        {
            Guid       expected     = new Guid(a, b, c, d, e, f, g, h, i, j, k);
            SACNPacket sourcePacket = new SACNPacket(1, "SourceName", expected, 1, new byte[512], 1);

            byte[] packetData = sourcePacket.ToArray();

            SACNPacket parsedPacket = SACNPacket.Parse(packetData);
            Guid       actual       = parsedPacket.RootLayer.UUID;

            Assert.Equal(expected, actual);
        }