Exemplo n.º 1
0
        public async Task DeviceFacade_CollectPressureParams_OnForcedRequest_Ok()
        {
            var remainingTime = TimeSpan.FromMinutes(1);
            var bedController =
                new Mock <IBedController>();

            bedController
            .Setup(x => x.GetRemainingTimeAsync())
            .Returns(async() =>
            {
                await Task.Yield();
                return(remainingTime);
            });
            bedController
            .Setup(x => x.GetCurrentIterationAsync())
            .Returns(Task.FromResult((short)1));

            bedController
            .Setup(x => x.GetNextIterationNumberForPressureMeasuringAsync())
            .Returns(Task.FromResult((short)1));

            var monitorController =
                Mock.Of <IMonitorController>();

            var facade = new DevicesFacade(_startParams,
                                           bedController.Object,
                                           monitorController,
                                           new WorkerController());

            var patientParamsCallsCount = 0;

            facade.OnPatientPressureParamsRecieved += (sender, span) => patientParamsCallsCount++;
            await facade.StartAsync().ConfigureAwait(false);

            await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);

            remainingTime = TimeSpan.Zero;
            await Task.Delay(TimeSpan.FromSeconds(3)).ConfigureAwait(false);

            await facade.ForceDataCollectionRequestAsync().ConfigureAwait(false);

            Assert.Equal(3, patientParamsCallsCount);
        }