Example #1
0
        public async Task FC06Test()
        {
            // Arrange
            var endpoint = EndpointSource.GetNext();

            using var server = new ModbusTcpServer();
            server.Start(endpoint);

            var client = new ModbusTcpClient();

            client.Connect(endpoint);

            // Act
            await client.WriteSingleRegisterAsync(0, 02, 259);

            await client.WriteSingleRegisterAsync(0, 10, 125);

            await client.WriteSingleRegisterAsync(0, 11, 16544);

            await client.WriteSingleRegisterAsync(0, 12, 4848);

            // Assert
            var expected = new short[] { 0, 0, 259, 0, 0, 0, 0, 0, 0, 0, 125, 16544, 4848 };

            lock (server.Lock)
            {
                var actual = server.GetHoldingRegisterBuffer <short>().Slice(0, 13).ToArray();
                Assert.True(expected.SequenceEqual(actual));
            }
        }