Exemplo n.º 1
0
        public async Task FC05Test()
        {
            // Arrange
            var endpoint = EndpointSource.GetNext();

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

            var client = new ModbusTcpClient();

            client.Connect(endpoint);

            // Act
            await client.WriteSingleCoilAsync(0, 2, true);

            await client.WriteSingleCoilAsync(0, 7, true);

            await client.WriteSingleCoilAsync(0, 9, true);

            await client.WriteSingleCoilAsync(0, 26, true);

            // Assert
            var expected = new byte[] { 132, 2, 0, 4 };

            lock (server.Lock)
            {
                var actual = server.GetCoilBuffer <byte>().Slice(0, 4).ToArray();
                Assert.True(expected.SequenceEqual(actual));
            }
        }