public void GetHoldingRegisterTest() { UInt16 index = 10; MemoryMap map = new MemoryMap(); map.AddHoldingRegister(new Register(index) { Value = 100 }); map.SetHoldingRegister(index, 100); UInt16 result = map.GetHoldingRegister(index); Assert.AreEqual(result, 100); }
public void FuncWriteSingleRegisterTest() { UInt16 index = 0; UInt16 register = 0; List <byte> expected = new List <byte>(); List <byte> writedValue = new List <byte>(); expected.Add(0xAA); expected.Add(0xBB); MemoryMap memory = new MemoryMap(); memory.AddHoldingRegister(new Register(0) { Value = 100 }); FunctionsImplementation imp = new FunctionsImplementation(memory); imp.FuncWriteSingleRegister(index, 0xAABB); register = memory.GetHoldingRegister(0); writedValue.AddRange(Utility.GetBytesFromReg(register)); Assert.AreEqual(expected[0], writedValue[0]); Assert.AreEqual(expected[1], writedValue[1]); }