public void OscBundleConstructorTest()
        {
            OscTimeTag timestamp = new OscTimeTag(14236589681638796952);
            OscMessage[] messages = new OscMessage[] { UnitTestHelper.Message_Array_Ints(),  UnitTestHelper.Message_Array_Ints() };
            OscBundle target = new OscBundle(timestamp, messages);

            Assert.AreEqual(timestamp, target.Timestamp);
            UnitTestHelper.AreEqual(messages, target.ToArray());
        }
예제 #2
0
        public void WriteTest_Float()
        {
            byte[] expected = new byte[] { 0x41, 0xCA, 0x00, 0x00 };
            float  value    = 25.25F;

            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    Helper.Write(writer, value);

                    UnitTestHelper.AreEqual(expected, stream.GetBuffer(), stream.Length);
                }
        }
예제 #3
0
        public void WriteTest_UInt64()
        {
            byte[] expected = new byte[] { 0xA1, 0xC2, 0xE3, 0xF4, 0xA5, 0xC6, 0xE7, 0xF8 };
            ulong  value    = 0xA1C2E3F4A5C6E7F8;

            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    Helper.Write(writer, value);

                    UnitTestHelper.AreEqual(expected, stream.GetBuffer(), stream.Length);
                }
        }
예제 #4
0
        public void WriteTest_UInt32()
        {
            byte[] expected = new byte[] { 0xAB, 0xCD, 0xEF, 0xF2 };
            uint   value    = 0xABCDEFF2;

            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    Helper.Write(writer, value);

                    UnitTestHelper.AreEqual(expected, stream.GetBuffer(), stream.Length);
                }
        }
예제 #5
0
        public void WriteTest_Double()
        {
            // 0x4028d8c7e28240b8
            // 12.4234
            byte[] expected = new byte[] { 0x40, 0x28, 0xd8, 0xc7, 0xe2, 0x82, 0x40, 0xb8 };
            double value    = 12.4234;

            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    Helper.Write(writer, value);

                    UnitTestHelper.AreEqual(expected, stream.GetBuffer(), stream.Length);
                }
        }
        public void ReadTest()
        {
            OscTimeTag timestamp = new OscTimeTag(14236589681638796952);
            OscMessage[] messages = new OscMessage[] { UnitTestHelper.Message_Array_Ints(), UnitTestHelper.Message_Array_Ints() };
            OscBundle expected = new OscBundle(timestamp, messages);

            byte[] bytes = expected.ToByteArray();
            int index = 0;
            int count = bytes.Length;
            OscBundle actual;
            actual = OscBundle.Read(bytes, index, count);
            UnitTestHelper.AreEqual(expected, actual);

            Assert.IsTrue(actual.Equals(expected));
        }
예제 #7
0
        public void ReadTest_MultiLine()
        {
            using (MemoryStream stream = new MemoryStream())
                using (StreamWriter writer = new StreamWriter(stream))
                    using (OscReader target = new OscReader(stream, OscPacketFormat.String))
                    {
                        writer.WriteLine(UnitTestHelper.BundleString_MultiLineString);
                        writer.Flush();
                        stream.Position = 0;

                        OscPacket expected = UnitTestHelper.Bundle_MultiLineString();
                        OscPacket actual;

                        actual = target.Read();

                        UnitTestHelper.AreEqual(expected, actual);
                    }
        }