Ejemplo n.º 1
0
        public async Task <ActionResult <IEnumerable <BatteryUsage> > > GetAverageDailyBatteryUsageAsync()
        {
            var result = await _batteryBusiness
                         .GetAverageDailyBatteryUsageAsync()
                         .ConfigureAwait(false);

            return(Ok(result ?? new List <BatteryUsage>()));
        }
        public async Task GetAverageDailyBatteryUsageAsync_ReturnsSuccessResult_SingleBatteryNotCharged()
        {
            //arrange
            IEnumerable <Battery> batteries = GetBatteryDataPointsWithoutChargeInBetween();

            _mockBatteryRepo
            .Setup(x => x.GetBatteriesAsync())
            .ReturnsAsync(batteries);

            //act
            var result = await _batteryBusiness
                         .GetAverageDailyBatteryUsageAsync()
                         .ConfigureAwait(false);

            //assert
            Assert.IsNotNull(result);
            var average = result.FirstOrDefault();

            Assert.AreEqual(average.SerialNumber, "Device-1");
            Assert.AreEqual(average.AverageDailyBatteryUsage, "0.08");
            Assert.AreEqual(average.NeedsReplacement, false);
        }