Ejemplo n.º 1
0
            void IOperationAcceptor.Accept(NetworkSetupOperation operation)
            {
                Guard.NotNull(operation, nameof(operation));

                IWirelessDevice?targetDevice = GetPoweredOnDeviceWithAddressOrNull(operation.DestinationAddress);

                targetDevice?.Accept(operation);
            }
        public void When_reading_network_setup_operation_it_must_be_correct()
        {
            // Arrange
            byte[] buffer =
            {
                2,
                ByteFor('0'),
                ByteFor('4'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('D'),
                ByteFor('E'),
                ByteFor('F'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('7'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('0'),
                ByteFor(':'),
                ByteFor('7'),
                ByteFor('\t'),
                3
            };

            var reader = new PacketReader();

            // Act
            Operation operation = reader.Read(buffer);

            // Assert
            var expected = new NetworkSetupOperation(new WirelessNetworkAddress("ABCDEF"), true,
                                                     DeviceRoles.StartTimer | DeviceRoles.FinishTimer | DeviceRoles.Keypad);

            operation.Should().BeEquivalentTo(expected, options => options.IncludingAllRuntimeProperties());
        }
        public void When_writing_network_setup_operation_it_must_be_correct()
        {
            // Arrange
            var operation = new NetworkSetupOperation(new WirelessNetworkAddress("ABCDEF"), true,
                                                      DeviceRoles.StartTimer | DeviceRoles.FinishTimer | DeviceRoles.Keypad);

            // Act
            byte[] buffer = PacketWriter.Write(operation, false);

            // Assert
            buffer.Should().BeEquivalentTo(new byte[]
            {
                2,
                ByteFor('0'),
                ByteFor('4'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('D'),
                ByteFor('E'),
                ByteFor('F'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('7'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('0'),
                ByteFor(':'),
                ByteFor('7'),
                ByteFor('\t'),
                3
            });
        }
 public void Accept(NetworkSetupOperation operation)
 {
 }
Ejemplo n.º 5
0
 void IWirelessDevice.Accept(NetworkSetupOperation operation)
 {
     // Not applicable for a mediator.
 }