public async Task ListLatestReleaseSubjects() { var subjects = new List <SubjectViewModel>(); var publicationId = Guid.NewGuid(); var release = new Release { Id = Guid.NewGuid() }; var(controller, mocks) = BuildControllerAndMocks(); var cacheKey = new ReleaseSubjectsCacheKey("publication", "release", release.Id); mocks .cacheKeyService .Setup(s => s.CreateCacheKeyForReleaseSubjects(release.Id)) .ReturnsAsync(cacheKey); mocks.cacheService .Setup(s => s.GetItem(cacheKey, typeof(List <SubjectViewModel>))) .ReturnsAsync(null); mocks .publicationService .Setup(s => s.GetLatestRelease(publicationId)) .Returns(release); mocks .releaseService .Setup(s => s.ListSubjects(release.Id)) .ReturnsAsync(subjects); mocks.cacheService .Setup(s => s.SetItem <object>(cacheKey, subjects)) .Returns(Task.CompletedTask); var result = await controller.ListLatestReleaseSubjects(publicationId); VerifyAllMocks(mocks); result.AssertOkResult(subjects); }
private async Task <Either <ActionResult, List <SubjectViewModel> > > ListLatestReleaseSubjects(ReleaseSubjectsCacheKey cacheKey) { return(await _releaseService.ListSubjects(cacheKey.ReleaseId)); }