public async Task InterpretData(BarometerProducer producer) { float expected = producer == BarometerProducer.Pressure ? 101173.828125f : -480.8828125f, actual = 0; byte[] response = producer == BarometerProducer.Pressure ? new byte[] { 0x12, 0x01, 0xd3, 0x35, 0x8b, 0x01 } : new byte[] { 0x12, 0x02, 0x1e, 0x1f, 0xfe, 0xff }; var route = await(producer == BarometerProducer.Pressure ? barometer.Pressure : barometer.Altitude) .AddRouteAsync(source => source.Stream(data => actual = data.Value <float>())); platform.sendMockResponse(response); Assert.That(actual, Is.EqualTo(expected).Within(0.00000001)); }
public async Task CreateAndRemoveStreamAsync(BarometerProducer producer) { byte mask = (byte)((int)producer + 1); byte[][] expected = { new byte[] { 0x12, mask, 0x1 }, new byte[] { 0x12, mask, 0x0 }, }; var route = await(producer == BarometerProducer.Pressure ? barometer.Pressure : barometer.Altitude) .AddRouteAsync(source => source.Stream(null)); route.Remove(); Assert.That(platform.GetCommands(), Is.EqualTo(expected)); }