public async Task <ActionResult <LatestUploadReport> > GetLatestUploads([FromQuery] ReportRequest reportRequest) { if (!IsReportRequestValid(reportRequest)) { return(BadRequest("document data incomplete")); } LatestUploadReport report = await _manager.GetLatestUploadsReport(reportRequest.Quantity, reportRequest.Unit); return(Ok(report)); }
public async void GetLatestUploadsReportShouldApplyUnitFilter() { int hours = 4; var repositoryMock = new Mock <ITrackingMemoryRepository>(); repositoryMock.Setup(mock => mock.GetItemsInLastNHoursAsync(It.IsAny <int>())); TrackingManager tm = new TrackingManager(repositoryMock.Object); await tm.GetLatestUploadsReport(hours, ReportUnit.Units); repositoryMock.Verify(mock => mock.GetLastNItemsAsync(hours), Times.Once); }
public async void GetLatestUploadsReportShouldRaiseExceptionWithWrongParameter() { int hours = 0; var repositoryMock = new Mock <ITrackingMemoryRepository>(); repositoryMock.Setup(mock => mock.GetItemsInLastNHoursAsync(It.IsAny <int>())); TrackingManager tm = new TrackingManager(repositoryMock.Object); await Assert.ThrowsAsync <ArgumentException>(async() => await tm.GetLatestUploadsReport(hours, ReportUnit.Hours)); repositoryMock.Verify(mock => mock.GetItemsInLastNHoursAsync(hours), Times.Never); }