public void Given30Messages2DaysApart_StartingAt100AndDecreasingBy2BetweenEachMessage_DaysLeftEquals59() { Guid customerId = Guid.NewGuid(); Guid deviceId = Guid.NewGuid(); List <MonitoringMessage> messages = new MonitoringMessageListBuilder(customerId, deviceId).AListOfMessages(29, 1, 100, 1).Build(); ForecastingEngine engine = new ForecastingEngine(); DeviceForecast forecast = engine.CalculateDeviceConsumableForecast(messages, deviceId); // 4 consumables for this device, all are decreasing at the same rate of 1 percent per day // which means they have 50 days left until hitting 10 percent Assert.AreEqual(4, forecast.ConsumableForecasts.Count); Assert.IsFalse(forecast.ConsumableForecasts.Any(x => x.CurrentLevel != 61)); Assert.IsFalse(forecast.ConsumableForecasts.Any(x => x.AverageDailyUse != 1)); Assert.IsFalse(forecast.ConsumableForecasts.Any(x => x.DaysRemainingToTenPercent != 50)); }
public DeviceForecast CalculateDeviceConsumableForecast(List <MonitoringMessage> messages, Guid deviceId) { DeviceForecast forecast = new DeviceForecast(); foreach (MonitoringMessage message in messages.OrderByDescending(x => x.LastReportedAt)) { //if level is greater than last reported, they probably replaced the cartridge and this report should not be counted toward average //calculate average daily use, keep in mind it might not have been reported every day (some days may have been skipped) //calculate Days remaining until ten percent left //if level is 0, stop counting usage towards average } return(forecast); }
public DeviceForecast CalculateDeviceConsumableForecast(List<MonitoringMessage> messages, Guid deviceId) { DeviceForecast forecast = new DeviceForecast(); foreach (MonitoringMessage message in messages.OrderByDescending(x => x.LastReportedAt)) { //if level is greater than last reported, they probably replaced the cartridge and this report should not be counted toward average //calculate average daily use, keep in mind it might not have been reported every day (some days may have been skipped) //calculate Days remaining until ten percent left //if level is 0, stop counting usage towards average } return forecast; }