Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }