Example #1
0
        public static DeviceAction FromOperation(NotifyActionOperation operation)
        {
            Guard.NotNull(operation, nameof(operation));

            // Justification for nullable suppression: Operation has been validated for required parameters when this code is reached.
            return(new DeviceAction(operation.OriginatingAddress !, operation.InputKeys, operation.SensorTime));
        }
        public void When_reading_notify_action_operation_it_must_be_correct()
        {
            // Arrange
            byte[] buffer =
            {
                2,
                ByteFor('5'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('5'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('D'),
                ByteFor('E'),
                ByteFor('F'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('6'),
                ByteFor('6'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('5'),
                ByteFor(':'),
                ByteFor('4'),
                ByteFor('5'),
                ByteFor('7'),
                ByteFor('\t'),
                3
            };

            var reader = new PacketReader();

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

            // Assert
            var expected = new NotifyActionOperation(new WirelessNetworkAddress("ABCDEF"))
            {
                InputKeys  = RawDeviceKeys.Key2OrPassIntermediate | RawDeviceKeys.Key7,
                SensorTime = TimeSpan.FromMilliseconds(456.75)
            };

            operation.Should().BeEquivalentTo(expected, options => options.IncludingAllRuntimeProperties());
        }
        public void When_writing_notify_action_operation_it_must_be_correct()
        {
            // Arrange
            var operation = new NotifyActionOperation(new WirelessNetworkAddress("ABCDEF"))
            {
                InputKeys  = RawDeviceKeys.Key2OrPassIntermediate | RawDeviceKeys.Key7,
                SensorTime = TimeSpan.FromMilliseconds(456.75)
            };

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

            // Assert
            buffer.Should().BeEquivalentTo(new byte[]
            {
                2,
                ByteFor('5'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('5'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('D'),
                ByteFor('E'),
                ByteFor('F'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('6'),
                ByteFor('6'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('5'),
                ByteFor(':'),
                ByteFor('4'),
                ByteFor('5'),
                ByteFor('7'),
                ByteFor('\t'),
                3
            });
        }
 public void Accept(NotifyActionOperation operation)
 {
 }
Example #5
0
 void IOperationAcceptor.Accept(NotifyActionOperation operation)
 {
 }