public void Accept(NotifyStatusOperation operation) { AssignmentStateMachine stateMachine = AssertStateMachineIsAssigned(assignmentStateMachine); stateMachine.ExecuteIfInPhase <PhaseWaitingForSetupResponse>(phase => phase.NewAddress == operation.OriginatingAddress ? new PhaseAssignmentCompleted(null) : null); }
public static DeviceStatus FromOperation(NotifyStatusOperation operation) { Guard.NotNull(operation, nameof(operation)); // Justification for nullable suppression: Operation has been validated for required parameters when this code is reached. return(new DeviceStatus(operation.OriginatingAddress !, operation.GetMembership !.Value, operation.Capabilities !.Value, operation.Roles !.Value, operation.SignalStrength !.Value, operation.BatteryStatus, operation.IsAligned, operation.ClockSynchronization, operation.HasVersionMismatch)); }
public void When_reading_notify_status_operation_it_must_be_correct() { // Arrange byte[] buffer = { 2, ByteFor('5'), ByteFor('2'), 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('1'), ByteFor('6'), ByteFor(':'), ByteFor('1'), ByteFor('\t'), ByteFor('0'), ByteFor('1'), ByteFor('9'), ByteFor(':'), ByteFor('3'), ByteFor('2'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('0'), ByteFor(':'), ByteFor('3'), ByteFor('2'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('1'), ByteFor(':'), ByteFor('2'), ByteFor('5'), ByteFor('3'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('2'), ByteFor(':'), ByteFor('2'), ByteFor('4'), ByteFor('1'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('3'), ByteFor(':'), ByteFor('1'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('7'), ByteFor(':'), ByteFor('1'), ByteFor('\t'), 3 }; var reader = new PacketReader(); // Act Operation operation = reader.Read(buffer); // Assert var expected = new NotifyStatusOperation(new WirelessNetworkAddress("ABCDEF"), true, DeviceCapabilities.TimeSensor, DeviceRoles.IntermediateTimer3, 253) { BatteryStatus = 241, IsAligned = true, ClockSynchronization = ClockSynchronizationStatus.RequiresSync }; operation.Should().BeEquivalentTo(expected, options => options.IncludingAllRuntimeProperties()); }
void IOperationAcceptor.Accept(NotifyStatusOperation operation) { }
public void When_writing_notify_status_operation_it_must_be_correct() { // Arrange var operation = new NotifyStatusOperation(new WirelessNetworkAddress("ABCDEF"), true, DeviceCapabilities.TimeSensor, DeviceRoles.IntermediateTimer3, 253) { BatteryStatus = 241, IsAligned = true, ClockSynchronization = ClockSynchronizationStatus.RequiresSync }; // Act byte[] buffer = PacketWriter.Write(operation, false); // Assert buffer.Should().BeEquivalentTo(new byte[] { 2, ByteFor('5'), ByteFor('2'), 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('1'), ByteFor('6'), ByteFor(':'), ByteFor('1'), ByteFor('\t'), ByteFor('0'), ByteFor('1'), ByteFor('9'), ByteFor(':'), ByteFor('3'), ByteFor('2'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('0'), ByteFor(':'), ByteFor('3'), ByteFor('2'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('1'), ByteFor(':'), ByteFor('2'), ByteFor('5'), ByteFor('3'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('2'), ByteFor(':'), ByteFor('2'), ByteFor('4'), ByteFor('1'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('3'), ByteFor(':'), ByteFor('1'), ByteFor('\t'), ByteFor('0'), ByteFor('2'), ByteFor('7'), ByteFor(':'), ByteFor('1'), ByteFor('\t'), 3 }); }