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); }
TryWriteWithoutResponseAsync_ForCharacteristicDoesNotSupportWrite_DoesNotCallTryWriteValueAsync( RawValueWriter sut, [Freeze] IGattCharacteristicWrapper characteristic, IBuffer buffer) { characteristic.WithCharacteristicProperties(GattCharacteristicProperties.None); await sut.TryWriteValueAsync(characteristic, buffer); await characteristic.DidNotReceive( ) .WriteValueAsync(buffer); }
public async Task TryWriteValueAsync_ForGattCommunicationStatusIsAccessDenied_False( RawValueWriter sut, [Freeze] IGattCharacteristicWrapper characteristic, IBuffer buffer) { characteristic.WithCharacteristicProperties(GattCharacteristicProperties.Write) .WithWriteValueAsyncResult(GattCommunicationStatus.AccessDenied); var actual = await sut.TryWriteValueAsync(characteristic, buffer); actual.Should( ) .BeFalse( ); }
public async Task TryWritableAuxiliariesValueAsync_ForCharacteristicDoesNotSupportWrite_False( RawValueWriter sut, [Freeze] IGattCharacteristicWrapper characteristic, IBuffer buffer) { characteristic.WithCharacteristicProperties(GattCharacteristicProperties.None) .WithWriteValueAsyncResult(GattCommunicationStatus.AccessDenied); var actual = await sut.TryWritableAuxiliariesValueAsync(characteristic, buffer); actual.Should( ) .BeFalse( ); }
public async Task TryWritableAuxiliariesValueAsync_ForGattCommunicationStatusIsProtocolError_False( RawValueWriter sut, [Freeze] IGattCharacteristicWrapper characteristic, IBuffer buffer) { characteristic.WithCharacteristicProperties(GattCharacteristicProperties.WritableAuxiliaries) .WithWriteValueAsyncResult(GattCommunicationStatus.ProtocolError); var actual = await sut.TryWritableAuxiliariesValueAsync(characteristic, buffer); actual.Should( ) .BeFalse( ); }
TryWriteWithoutResponseAsync_ForCharacteristicDoesNotWriteWithoutResponse_GattWriteResultNotSupported( RawValueWriter sut, [Freeze] IGattCharacteristicWrapper characteristic, IBuffer buffer, IGattWriteResultWrapper result) { characteristic.WithCharacteristicProperties(GattCharacteristicProperties.None) .WithWriteValueWithResultAsync(result); var actual = await sut.TryWriteWithoutResponseAsync(characteristic, buffer); actual.Should( ) .Be(GattWriteResultWrapper.NotSupported); }
public async Task TryWriteWithoutResponseAsync_ForGattCommunicationStatusIsAccessDenied_False( RawValueWriter sut, [Freeze] IGattCharacteristicWrapper characteristic, IBuffer buffer, IGattWriteResultWrapper result) { characteristic.WithCharacteristicProperties(GattCharacteristicProperties.WriteWithoutResponse) .WithWriteValueWithResultAsync(result); var actual = await sut.TryWriteWithoutResponseAsync(characteristic, buffer); actual.Should( ) .Be(result); }
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); }