public async Task TryReadValueAsync_ForGattCommunicationStatus_SetsProtocolError( RawValueReader sut, [Freeze] IBufferReader reader, IGattReadResultWrapper result, IGattCharacteristicWrapper characteristic, byte protocolError) { WithTryReadValueResult(reader, Array.Empty <byte> ( )); result.Status .Returns(GattCommunicationStatus.Success); result.ProtocolError .Returns(protocolError); characteristic.WithCharacteristicProperties(GattCharacteristicProperties.Read) .WithReadValueAsyncResult(result); _ = await sut.TryReadValueAsync(characteristic); sut.ProtocolError .Should( ) .Be(protocolError); }
public static IGattCharacteristicWrapper WithReadValueAsyncResult( this IGattCharacteristicWrapper characteristic, IGattReadResultWrapper result) { _ = characteristic.ReadValueAsync( ) .Returns(Task.FromResult(result)); return(characteristic); }
public async Task TryReadValueAsync_ForNotSupportingRead_Empty( RawValueReader sut, [Freeze] IBufferReader reader, IGattReadResultWrapper result, IGattCharacteristicWrapper characteristic) { WithTryReadValueResult(reader, Array.Empty <byte> ( )); result.Status .Returns(GattCommunicationStatus.Success); characteristic.WithCharacteristicProperties(GattCharacteristicProperties.None) .WithReadValueAsyncResult(result); var(_, bytes) = await sut.TryReadValueAsync(characteristic); bytes.Should( ) .BeEmpty( ); }
public async Task TryReadValueAsync_ForSupportsNotifyTrue_False( RawValueReader sut, [Freeze] IBufferReader reader, IGattReadResultWrapper result, IGattCharacteristicWrapper characteristic) { WithTryReadValueResult(reader, Array.Empty <byte> ( )); result.Status .Returns(GattCommunicationStatus.Success); characteristic.WithCharacteristicProperties(GattCharacteristicProperties.Notify) .WithReadValueAsyncResult(result); var(success, _) = await sut.TryReadValueAsync(characteristic); success.Should( ) .BeFalse( ); }
public async Task TryReadValueAsync_ForGattCommunicationStatusIsSuccess_Bytes( RawValueReader sut, [Freeze] IBufferReader reader, IGattReadResultWrapper result, IGattCharacteristicWrapper characteristic, byte [] bytes) { WithTryReadValueResult(reader, bytes); result.Status .Returns(GattCommunicationStatus.Success); characteristic.WithCharacteristicProperties(GattCharacteristicProperties.Read) .WithReadValueAsyncResult(result); var(_, value) = await sut.TryReadValueAsync(characteristic); value.Should( ) .BeEquivalentTo(bytes); }