public void GetRegisterFromIndexer()
        {
            Register expected = new Register(RegisterType.R0, 0);

            byte[] networkData = PacketTypesTest.CreateNetworkRegisters();
            this.SendPacket("", BitConverter.ToString(networkData).Replace("-", ""));

            Register actual = manager[RegisterType.R0];
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(ErrorCode.NoError, this.Client.Error);
        }
示例#2
0
        public void CreateWriteSingleRegisterCommand()
        {
            Register register = new Register(RegisterType.R12, 0x5040);

            WriteSingleRegister cmd = new WriteSingleRegister(register);
            Assert.AreEqual("P", cmd.Command);
            Assert.AreEqual("P0C000000=40500000", cmd.Pack());
        }
示例#3
0
 public void CreateRegistersReply()
 {
     Register[] registers = new Register[] {
         new Register((RegisterType)0, 0x1423),
         new Register((RegisterType)1, 0x3412)};
     RegistersReply reply = new RegistersReply(registers);
     Assert.AreEqual(registers, reply.GetRegisters());
 }
        private void TestGetRegister(RegisterType type)
        {
            Register expected = new Register(type, (uint)type);

            byte[] networkData = PacketTypesTest.CreateNetworkRegisters();
            this.SendPacket("", BitConverter.ToString(networkData).Replace("-", ""));

            Register actual = manager.GetRegister(type);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(ErrorCode.NoError, this.Client.Error);
        }
        public void WriteSingleQueryWithIndexer()
        {
            Register register = new Register(RegisterType.R1, 0x2);
            string expected = "P01000000=02000000";

            this.SendPacket("OK", "");
            manager[RegisterType.R1] = register;
            Assert.AreEqual(ErrorCode.NoError, this.Client.Error);

            string rcv = this.Read();
            Assert.AreEqual(expected, rcv.Substring(1, rcv.Length - 5));
        }