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); }
public void ReadUInt32Test_LittleEndian() { var endianess = Endianness.LittleEndian; DataBuffer target = new DataBuffer(endianess); UInt32 expected = 0xFFAABB22; var data = new byte[] { 0x22, 0xBB, 0xAA, 0xFF }; target.WriteRawData(data); var actual = target.ReadUInt32(); Assert.AreEqual(expected, actual); }
public void WriteDoubleTest_LittleEndian() { var endianess = Endianness.LittleEndian; DataBuffer target = new DataBuffer(endianess); double data = 365784e40; var expected = BitConverter.GetBytes(data); target.WriteDouble(data); var actual = target.RawData; CollectionAssert.AreEqual(expected, actual); }
public void ReadDoubleTest_LittleEndian() { var endianess = Endianness.LittleEndian; DataBuffer target = new DataBuffer(endianess); double expected = 365784e40; var expectedBytes = BitConverter.GetBytes(expected); target.WriteRawData(expectedBytes); var actual = target.ReadDouble(); Assert.AreEqual(expected, actual); }
public void FromBufferTest() { var target = new AccelData(15.0, 75.0); var expected = new AccelData(20.0, -75.0); var buffer = new DataBuffer(Endianness.LittleEndian); buffer.WriteDouble(20.0); buffer.WriteDouble(-75.0); target.FromBuffer(buffer); Assert.AreEqual(expected.Ax, target.Ax); Assert.AreEqual(expected.Ay, target.Ay); }
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); }
public void ToBufferTest() { var target = new AccelData(20.0, -75.0); var expected = new byte[] {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); }
public void ConstructorTest() { var endianess = Endianness.BigEndian; DataBuffer target = new DataBuffer(endianess); Assert.AreEqual(endianess,target.ByteOrder); }
public void WriteUInt32Test_LittleEndian() { var endianess = Endianness.LittleEndian; DataBuffer target = new DataBuffer(endianess); var expected = new byte[] { 0x22, 0xBB, 0xAA, 0xFF }; target.WriteUInt32(0xFFAABB22); Assert.AreEqual(expected.Length, target.UnreadedData); CollectionAssert.AreEqual(expected, target.RawData); }
public void WriteRawDataTest() { var endianess = Endianness.BigEndian; DataBuffer target = new DataBuffer(endianess); var data = new byte[10]; target.WriteRawData(data); Assert.AreEqual(data.Length, target.UnreadedData); CollectionAssert.AreEqual(data, target.RawData); }
public object Clone() { DataBuffer buffer = new DataBuffer(this.ByteOrder); buffer.WriteRawData(this.RawData); return buffer; }