Ejemplo n.º 1
0
        public void FromBufferTest()
        {
            var target = new AccelParams();

            var expected = new AccelParams
                               {
                                   SensorNumber = 1,
                                   OffsetX = 20.0,
                                   OffsetY = -75.0,
                                   GravityX = -20.0,
                                   GravityY = 75.0
                               };

            var buffer = new DataBuffer(Endianness.LittleEndian);
            buffer.WriteUInt16(1);
            buffer.WriteDouble(20.0);
            buffer.WriteDouble(-75.0);
            buffer.WriteDouble(-20.0);
            buffer.WriteDouble(75.0);

            target.FromBuffer(buffer);

            var tt = new DataBuffer(Endianness.LittleEndian);
            target.ToBuffer(tt);

            Assert.AreEqual(expected.SensorNumber,target.SensorNumber);
            Assert.AreEqual(expected.OffsetX, target.OffsetX);
            Assert.AreEqual(expected.OffsetY, target.OffsetY);
            Assert.AreEqual(expected.GravityX, target.GravityX);
            Assert.AreEqual(expected.GravityY, target.GravityY);
        }
Ejemplo n.º 2
0
        public void ToBufferTest()
        {
            var target = new AccelParams
                             {
                                 SensorNumber = 1,
                                 OffsetX = 20.0,
                                 OffsetY = -75.0,
                                 GravityX = 20.0,
                                 GravityY = -75.0
                             };

            var expected = new byte[] { 1,0,0, 0, 0, 0, 0, 0, 52, 64, 0, 0, 0, 0, 0, 192, 82, 192, 0, 0, 0, 0, 0, 0, 52, 64, 0, 0, 0, 0, 0, 192, 82, 192 };

            var buffer = new DataBuffer(Endianness.LittleEndian);

            target.ToBuffer(buffer);

            CollectionAssert.AreEqual(expected, buffer.RawData);
        }