/// <summary> /// Get the overview of the inventory broke down by the Freshness of the Batches/Portions. /// </summary> /// <returns> /// A Task which resolves in the Overview /// </returns> public async Task <OverviewByFreshness> GetOverviewByFreshness() { OverviewByFreshness overview = new OverviewByFreshness(); // Get the list of all Batches List <Batch> allBatches = await DataHandler.GetData <Batch>(DataSource.Batches); // Add the batches to the overview overview.AddBatchesToOverview(allBatches); // return the overview return(overview); }
public async void VerifyGetOverviewByFreshness() { OverviewByFreshness overview = new OverviewByFreshness(); overview.AddBatchesToOverview(batchList); mockAccessService.Setup(a => a.GetOverviewByFreshness()) .ReturnsAsync(overview); ActionResult actionResult = await this.controller.GetOverviewByFreshness(); OkObjectResult objResult = Assert.IsType <OkObjectResult>(actionResult); Assert.Equal(200, objResult.StatusCode); mockAccessService.Verify(a => a.GetOverviewByFreshness(), Times.Once); }
public void VerifyAddExpiringBatchesToOverview() { OverviewByFreshness overview = new OverviewByFreshness(); Batch b = Batch.GetInstance(Guid.NewGuid(), 400); b.Expiration = DateTime.UtcNow.AddHours(10); List <Batch> list = new List <Batch> { b }; overview.AddBatchesToOverview(list); Assert.IsTrue(overview.ExpiringTodayBatches == 1); Assert.IsTrue(overview.ExpiringTodayPortions == b.AvailableQuantity); }
public async Task <ActionResult> GetOverviewByFreshness() { OverviewByFreshness overview = await AccessService.GetOverviewByFreshness(); return(Ok(overview)); }