Ejemplo n.º 1
0
                public override T Value <T>()
                {
                    var type = typeof(T);

                    if (type == typeof(AnyMotion))
                    {
                        bool detected(byte axis, byte value)
                        {
                            byte mask = (byte)(0x1 << (axis + 3));

                            return((value & mask) == mask);
                        }

                        byte      highFirst = (byte)((bytes[0] & 0x1c) >> 2);
                        AnyMotion casted    = new AnyMotion(
                            (bytes[0] & 0x40) == 0x40 ? Sign.Negative : Sign.Positive,
                            detected(0, bytes[0]),
                            detected(1, bytes[0]),
                            detected(2, bytes[0]));


                        return((T)Convert.ChangeType(casted, type));
                    }

                    return(base.Value <T>());
                }
Ejemplo n.º 2
0
            public async Task HandleData(AnyMotion expected, byte[] response)
            {
                AnyMotion actual = null;

                await accelerometer.Motion.AddRouteAsync(source => source.Stream(data => actual = data.Value <AnyMotion>()));

                platform.sendMockResponse(response);

                Assert.That(actual, Is.EqualTo(expected));
            }