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);
        }
Example #2
0
 public void Create_ForInvoked_Instance(
     GattCharacteristicsProviderFactory sut,
     IGattCharacteristicsResultWrapper wrapper)
 {
     sut.Create(wrapper)
     .Should( )
     .NotBeNull( );
 }
        public void Indexer_ForServiceAndResult_UpdatesCount(
            GattServicesDictionary sut,
            IGattDeviceServiceWrapper service,
            IGattCharacteristicsResultWrapper result)
        {
            sut [service] = result;

            sut.Count
            .Should( )
            .Be(1);
        }
        public void Indexer_ForServiceAndResult_SetsKeyAndValue(
            GattServicesDictionary sut,
            IGattDeviceServiceWrapper service,
            IGattCharacteristicsResultWrapper result)
        {
            sut [service] = result;

            sut [service]
            .Should( )
            .Be(result);
        }
        public void ReadOnlyDictionary_ForInvoked_ContainsService1(
            GattServicesDictionary sut,
            IGattDeviceServiceWrapper service,
            IGattCharacteristicsResultWrapper result)
        {
            sut [service] = result;

            sut.ReadOnlyDictionary [service]
            .Should( )
            .Be(result);
        }
        public GattCharacteristicProvider(
            [NotNull] ILogger logger,
            [NotNull] IGattCharacteristicsResultWrapper gattCharacteristics)
        {
            Guard.ArgumentNotNull(logger,
                                  nameof(logger));
            Guard.ArgumentNotNull(gattCharacteristics,
                                  nameof(gattCharacteristics));

            _logger = logger;
            _gattCharacteristics = gattCharacteristics;
        }
        public void Clear_ForInvoked_SetsCountToZero(
            GattServicesDictionary sut,
            IGattDeviceServiceWrapper service,
            IGattCharacteristicsResultWrapper result)
        {
            sut [service] = result;

            sut.Clear( );

            sut.Count
            .Should( )
            .Be(0);
        }
        public void Clear_ForInvoked_DisposesService2(
            GattServicesDictionary sut,
            IGattDeviceServiceWrapper service1,
            IGattCharacteristicsResultWrapper result1,
            IGattDeviceServiceWrapper service2,
            IGattCharacteristicsResultWrapper result2)
        {
            sut [service1] = result1;
            sut [service2] = result2;

            sut.Clear( );

            sut [service1] = result1;
            sut [service2] = result2;
        }
        public void Dispose_ForInvoked_DisposesService2(
            GattServicesDictionary sut,
            IGattDeviceServiceWrapper service1,
            IGattCharacteristicsResultWrapper result1,
            IGattDeviceServiceWrapper service2,
            IGattCharacteristicsResultWrapper result2)
        {
            sut [service1] = result1;
            sut [service2] = result2;

            sut.Dispose( );

            service2.Received( )
            .Dispose( );
        }
Example #10
0
 public IGattCharacteristicProvider Create(
     IGattCharacteristicsResultWrapper wrapper)
 {
     return(_factory(wrapper));
 }