示例#1
0
        public void OnDeskDetected_ForInvoked_CallsDeskDetectorStop(
            DeskProvider sut,
            [Freeze] IDeskDetector detector,
            IDesk desk)
        {
            sut.OnDeskDetected(desk);

            detector.Received( )
            .Stop( );
        }
示例#2
0
        public void StopDetecting_ForInvoked_CallsDeskDetectorStart(
            DeskProvider sut,
            [Freeze] IDeskDetector detector,
            string deviceName,
            ulong deviceAddress,
            uint deviceTimeout)
        {
            sut.Initialize(deviceName,
                           deviceAddress,
                           deviceTimeout)
            .StopDetecting( );

            detector.Received( )
            .Stop( );
        }
示例#3
0
        public async Task TryGetDesk_ForInvoked_CallsDeskDetectorStart(
            DeskProvider sut,
            [Freeze] IDeskDetector detector,
            CancellationTokenSource source,
            string deviceName,
            ulong deviceAddress,
            uint deviceTimeout)
        {
            await sut.Initialize(deviceName,
                                 deviceAddress,
                                 deviceTimeout)
            .TryGetDesk(source.Token);

            detector.Received( )
            .Start( );
        }
示例#4
0
        public async Task TryGetDesk_ForCancelled_ReturnsNullForDesk(
            DeskProvider sut,
            [Freeze] IDeskDetector detector,
            CancellationTokenSource source,
            string deviceName,
            ulong deviceAddress,
            uint deviceTimeout)
        {
            detector.When(x => x.Initialize(deviceName,
                                            deviceAddress,
                                            deviceTimeout))
            .Do(info => { source.Cancel( ); });

            var(_, desk) = await sut.Initialize(deviceName,
                                                deviceAddress,
                                                deviceTimeout)
                           .TryGetDesk(source.Token);

            desk.Should( )
            .BeNull( );
        }
示例#5
0
        public DeskProvider(
            [NotNull] ILogger logger,
            [NotNull] ITaskRunner taskRunner,
            [NotNull] IScheduler scheduler,
            [NotNull] IDeskDetector detector,
            [NotNull] IErrorManager errorManager)
        {
            Guard.ArgumentNotNull(logger,
                                  nameof(logger));
            Guard.ArgumentNotNull(taskRunner,
                                  nameof(taskRunner));
            Guard.ArgumentNotNull(scheduler,
                                  nameof(scheduler));
            Guard.ArgumentNotNull(detector,
                                  nameof(detector));
            Guard.ArgumentNotNull(errorManager,
                                  nameof(errorManager));

            _logger       = logger;
            _taskRunner   = taskRunner;
            _scheduler    = scheduler;
            _detector     = detector;
            _errorManager = errorManager;
        }