public async Task DeltaReportServiceGetDetailReturnsSuccess()
        {
            // Arrange
            var expectedResult = A.Dummy <DeltaReportModel>();
            var dummyCachedDeltaReportModel = A.Dummy <CachedDeltaReportModel>();
            var service = new DeltaReportService(fakeLogger, fakeDeltaReportApiConnector, dummyCachedDeltaReportModel);

            A.CallTo(() => fakeDeltaReportApiConnector.GetDetailAsync(A <Guid> .Ignored)).Returns(expectedResult);

            // Act
            var result = await service.GetDetailAsync(Guid.NewGuid()).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeDeltaReportApiConnector.GetDetailAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();

            A.Equals(expectedResult, result);
        }
Example #2
0
        public async Task <DeltaReportModel?> GetDetailAsync(Guid id)
        {
            if (cachedDeltaReportModel?.DeltaReportModel?.Id != null && cachedDeltaReportModel.DeltaReportModel.Id.Equals(id))
            {
                logger.LogInformation($"Returning cached delta report for: {id}");

                return(cachedDeltaReportModel.DeltaReportModel);
            }

            logger.LogInformation($"Retrieving delta report for: {id}");

            cachedDeltaReportModel !.DeltaReportModel = await deltaReportApiConnector.GetDetailAsync(id).ConfigureAwait(false);

            return(cachedDeltaReportModel.DeltaReportModel);
        }