Ejemplo n.º 1
0
        private void OnHeightSpeedChanged(RawValueChangedDetails details)
        {
            if (details == null)
            {
                return;
            }

            if (!_converter.TryConvert(details.Value,
                                       out var height,
                                       out var speed))
            {
                return;
            }

            Height = height;
            Speed  = speed;

            _subjectHeight.OnNext(Height);
            _subjectSpeed.OnNext(Speed);

            var value = new HeightSpeedDetails(details.Timestamp,
                                               Height,
                                               Speed);

            _subjectHeightAndSpeed.OnNext(value);

            _logger.Debug($"Height = {Height} (10ths of a millimeter), Speed = {Speed} (100/RPM)");
        }
Ejemplo n.º 2
0
        public async Task Refresh_ForInvoked_NotifiesHeightAndSpeed( )
        {
            var scheduler = new TestScheduler( );
            var subject   = new Subject <RawValueChangedDetails> ( );

            var sut = CreateSut(scheduler,
                                subject);

            RawValueChangedDetails heightAndSpeed = null;

            subject
            .ObserveOn(scheduler)
            .Subscribe(x => { heightAndSpeed = x; });

            ServiceWrapper.Uuid
            .Returns(sut.GattServiceUuid);

            sut.Initialize <ReferenceOutput> ( );

            await sut.Refresh( );

            scheduler.Start( );

            heightAndSpeed.Value
            .Should( )
            .BeEquivalentTo(RawValue1);
        }
Ejemplo n.º 3
0
        public void Initialize( )
        {
            _logger                   = Substitute.For <ILogger> ( );
            _scheduler                = new TestScheduler( );
            _referenceOutput          = Substitute.For <IReferenceOutput> ( );
            _converter                = Substitute.For <IRawValueToHeightAndSpeedConverter> ( );
            _subjectHeight            = new Subject <uint> ( );
            _subjectSpeed             = new Subject <int> ( );
            _subjectHeightAndSpeed    = new Subject <HeightSpeedDetails> ( );
            _subjectRawHeightAndSpeed = new Subject <RawValueChangedDetails> ( );

            SetTryConvert(_converter,
                          true,
                          DefaultHeight,
                          DefaultSpeed);

            _referenceOutput.HeightSpeedChanged
            .Returns(_subjectRawHeightAndSpeed);

            _rawDetailsDummy = new RawValueChangedDetails(string.Empty,
                                                          Array.Empty <byte> ( ),
                                                          DateTimeOffset.Now,
                                                          Guid.Empty);
        }