Exemplo n.º 1
0
        public void ConstructorTest()
        {
            var sut = new GetStarDataCommand(1);

            sut.CommandCode.Should().Be(0xca);
            sut.AcknowledgeCode.Should().Be(0xca);
            sut.SubCommandCode.Should().Be(0x39);
            sut.RequiredBaudRate.Should().Be(250000);
            sut.Timeout.Should().Be(1000);
        }
Exemplo n.º 2
0
        public void Exception_Test(byte errorCode, Type ex)
        {
            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x39 });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { errorCode });

            var    sut = new GetStarDataCommand(1);
            Action act = () => sut.Execute(ftdiMock.Object);

            TestDelegate test = new TestDelegate(act);

            MethodInfo method  = typeof(Assert).GetMethod("Throws", new[] { typeof(TestDelegate) });
            MethodInfo generic = method.MakeGenericMethod(ex);

            generic.Invoke(this, new object[] { test });
        }
Exemplo n.º 3
0
        public void Successful_Scenario_Test()
        {
            byte index      = 0x01;
            var  posX       = new byte[] { 0x33, 0x12 };
            var  posY       = new byte[] { 0x12, 0x33 };
            var  brightness = new byte[] { 0x01, 0x03 };
            byte pixels     = 0x65;
            byte peak       = 0x78;

            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x39 }, new byte[] { index });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { 0x00 }, new byte[] { index }, new byte[] { posX[0], posX[1], posY[0], posY[1], brightness[0], brightness[1], pixels, peak });

            var sut    = new GetStarDataCommand(index);
            var result = sut.Execute(ftdiMock.Object);

            result.Success.Should().BeTrue();
            result.PositionX.Should().Be((ushort)((posX[1] << 8) + posX[0]));
            result.PositionY.Should().Be((ushort)((posY[1] << 8) + posY[0]));
            result.Brightness.Should().Be((ushort)((brightness[1] << 8) + brightness[0]));
            result.Pixels.Should().Be(pixels);
            result.Peak.Should().Be(peak);
        }