public async Task Refresh_ForConnectedAndCharacteristicsUnreachable_DoesNotAddService( GattServicesProvider sut, [Freeze] IBluetoothLeDeviceWrapper device, [Freeze] IGattServicesDictionary services, IGattDeviceServicesResultWrapper result, IGattDeviceServiceWrapper service, IGattCharacteristicsResultWrapper characteristics) { result.Status .Returns(GattCommunicationStatus.Success); result.Services .Returns(new[] { service }); device.ConnectionStatus .Returns(BluetoothConnectionStatus.Connected); device.GetGattServicesAsync() .Returns(Task.FromResult(result)); characteristics.Status .Returns(GattCommunicationStatus.Unreachable); service.GetCharacteristicsAsync() .Returns(characteristics); await sut.Refresh(); services[service] .Should() .NotBe(characteristics); }
/// <inheritdoc /> public IGattServicesProvider Create(IBluetoothLeDeviceWrapper wrapper) { Guard.ArgumentNotNull(wrapper, nameof(wrapper)); return(_factory.Invoke(wrapper)); }
public void ConnectionStatus_ForInvoked_Instance( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { sut.ConnectionStatus .Should() .Be(wrapper.ConnectionStatus); }
public void GattServices_ForInvoked_Instance( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { sut.GattServices .Should() .BeSameAs(wrapper.GattServices); }
public void Name_ForInvoked_Instance( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { sut.Name .Should() .Be(wrapper.Name); }
public void IsPaired_ForInvoked_Instance( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { sut.IsPaired .Should() .Be(wrapper.IsPaired); }
public void GattCommunicationStatus_ForInvoked_Instance( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { sut.GattCommunicationStatus .Should() .Be(wrapper.GattCommunicationStatus); }
public void Create_ForWrapper_Instance( GattServicesProviderFactory sut, IBluetoothLeDeviceWrapper wrapper) { sut.Create(wrapper) .Should( ) .NotBeNull( ); }
public void Dispose_ForInvoked_DisposesWrapper( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { sut.Dispose(); wrapper.Received() .Dispose(); }
public void Connect_ForDisconnected_DoesCallConnect( Device sut, [Freeze] IBluetoothLeDeviceWrapper wrapper) { wrapper.ConnectionStatus .Returns(BluetoothConnectionStatus.Disconnected); sut.Connect(); wrapper.Received() .Connect(); }
public async Task Refresh_ForDisconnected_SetsGattCommunicationStatusUnreachable( GattServicesProvider sut, [Freeze] IBluetoothLeDeviceWrapper device) { device.ConnectionStatus .Returns(BluetoothConnectionStatus.Disconnected); await sut.Refresh(); sut.GattCommunicationStatus .Should() .Be(GattCommunicationStatus.Unreachable); }
public async Task Refresh_ForDisconnected_Notifies( GattServicesProvider sut, [Freeze] IBluetoothLeDeviceWrapper device, [Freeze] ISubject <GattCommunicationStatus> refreshed) { device.ConnectionStatus .Returns(BluetoothConnectionStatus.Disconnected); await sut.Refresh(); refreshed.Received() .OnNext(GattCommunicationStatus.Unreachable); }
public Device([NotNull] IScheduler scheduler, [NotNull] IBluetoothLeDeviceWrapper wrapper) { Guard.ArgumentNotNull(wrapper, nameof(wrapper)); Guard.ArgumentNotNull(scheduler, nameof(scheduler)); _wrapper = wrapper; _subscriber = _wrapper.ConnectionStatusChanged .SubscribeOn(scheduler) .Subscribe(_ => Connect( )); }
public void Constructor_ForDeviceNull_Throws( Lazy <GattServicesProvider> sut, [BeNull] IBluetoothLeDeviceWrapper device) { // ReSharper disable once UnusedVariable Action action = () => { var test = sut.Value; }; action.Should() .Throw <ArgumentNullException>() .WithParameter(nameof(device)); }
public void Dispose_ForInvoked_DisposesSubscriber( Lazy <Device> sut, [Freeze] IBluetoothLeDeviceWrapper wrapper, [Freeze] IDisposable subscriber, IObservable <BluetoothConnectionStatus> status) { status.Subscribe(_ => { }) .ReturnsForAnyArgs(subscriber); wrapper.ConnectionStatusChanged .Returns(status); sut.Value .Dispose(); subscriber.Received() .Dispose(); }
public GattServicesProvider([NotNull] ILogger logger, [NotNull] IGattServicesDictionary services, [NotNull] ISubject <GattCommunicationStatus> refreshed, [NotNull] IBluetoothLeDeviceWrapper device) { Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(services, nameof(services)); Guard.ArgumentNotNull(refreshed, nameof(refreshed)); Guard.ArgumentNotNull(device, nameof(device)); _logger = logger; _services = services; _refreshed = refreshed; _device = device; }
public async Task GattCommunicationStatus_ForConnectedAndServicesAvailable_Success( GattServicesProvider sut, [Freeze] IBluetoothLeDeviceWrapper device, IGattDeviceServicesResultWrapper resultWrapper) { resultWrapper.Status .Returns(GattCommunicationStatus.Success); device.ConnectionStatus .Returns(BluetoothConnectionStatus.Connected); device.GetGattServicesAsync() .Returns(resultWrapper); await sut.Refresh(); sut.GattCommunicationStatus .Should() .Be(resultWrapper.Status); }
public async Task Refresh_ForConnected_SetsGattCommunicationStatusUnreachable( GattServicesProvider sut, [Freeze] IBluetoothLeDeviceWrapper device, IGattDeviceServicesResultWrapper result) { result.Status .Returns(GattCommunicationStatus.Unreachable); device.ConnectionStatus .Returns(BluetoothConnectionStatus.Connected); device.GetGattServicesAsync() .Returns(Task.FromResult(result)); await sut.Refresh(); sut.GattCommunicationStatus .Should() .Be(GattCommunicationStatus.Unreachable); }
public async Task Refresh_ForConnected_Notifies( GattServicesProvider sut, [Freeze] IBluetoothLeDeviceWrapper device, [Freeze] ISubject <GattCommunicationStatus> refreshed, IGattDeviceServicesResultWrapper result) { var expected = GattCommunicationStatus.ProtocolError; result.Status .Returns(expected); device.ConnectionStatus .Returns(BluetoothConnectionStatus.Connected); device.GetGattServicesAsync() .Returns(Task.FromResult(result)); await sut.Refresh(); refreshed.Received() .OnNext(expected); }