예제 #1
0
        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());
 }
예제 #4
0
        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);
        }
예제 #5
0
        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));
        }