private ReleaseViewModel CreateRelease(string releaseName, int order, IList <PackageDto> packages) { var release = _packageOptions.Value.Releases .SingleOrDefault(r => r.Key.Equals(releaseName, StringComparison.InvariantCultureIgnoreCase)); packages = packages.OrderByDescending(p => p.PublishedAt).ToList(); var viewModel = new ReleaseViewModel { Title = release.Key, Description = release.Value, Type = release.Key, Order = order, Platforms = new List <PlatformViewModel> { CreatePlatform("Linux", 1, packages.Where(p => p.Platform.Equals("linux") && p.Name.Contains("nethermind"))), CreatePlatform("Mac", 1, packages.Where(p => p.Platform.Equals("darwin") && p.Name.Contains("nethermind"))), CreatePlatform("Windows", 1, packages.Where(p => p.Platform.Equals("windows") && p.Name.Contains("nethermind"))), CreatePlatform("NDM-Linux", 1, packages.Where(p => p.Platform.Equals("linux") && p.Name.Contains("NDM"))), CreatePlatform("NDM-Mac", 1, packages.Where(p => p.Platform.Equals("darwin") && p.Name.Contains("NDM"))), CreatePlatform("NDM-Windows", 1, packages.Where(p => p.Platform.Equals("windows") && p.Name.Contains("NDM"))) } }; return(viewModel); }
public async Task CreateReleaseStatus() { var releaseStatusViewModel = new ReleaseStatusCreateViewModel(); var returnedReleaseViewModel = new ReleaseViewModel(); var mocks = Mocks(); mocks .ReleaseApprovalService .Setup(s => s.CreateReleaseStatus(_releaseId, releaseStatusViewModel)) .ReturnsAsync(Unit.Instance); mocks .ReleaseService .Setup(s => s.GetRelease(_releaseId)) .ReturnsAsync(returnedReleaseViewModel); var controller = ReleasesControllerWithMocks(mocks); // Call the method under test var result = await controller.CreateReleaseStatus(releaseStatusViewModel, _releaseId); VerifyAllMocks(mocks); result.AssertOkResult(returnedReleaseViewModel); }
public ActionResult Index(string artistName, string releaseTitle) { var viewModel = new ReleaseViewModel { ArtistName = artistName, ReleaseTitle = releaseTitle }; return(View(viewModel)); }
public async Task Create_Release_Returns_Ok() { var returnedViewModel = new ReleaseViewModel(); var mocks = Mocks(); mocks .ReleaseService .Setup(s => s.CreateRelease(It.IsAny <ReleaseCreateViewModel>())) .ReturnsAsync(returnedViewModel); var controller = ReleasesControllerWithMocks(mocks); // Call the method under test var result = await controller.CreateRelease(new ReleaseCreateViewModel(), _publicationId); VerifyAllMocks(mocks.ReleaseService); result.AssertOkResult(returnedViewModel); }
public async Task <Either <ActionResult, ReleaseViewModel> > Get(string publicationSlug, string?releaseSlug = null) { return(await _publicationService.Get(publicationSlug) .OnSuccessCombineWith(publication => _methodologyService.GetSummariesByPublication(publication.Id)) .OnSuccess(async tuple => { var(publication, methodologies) = tuple; return await GetCachedRelease(publicationSlug, releaseSlug) .OnSuccess(cachedRelease => { var result = new ReleaseViewModel( _mapper.Map <CachedReleaseViewModel>(cachedRelease), _mapper.Map <PublicationViewModel>(publication) ); result.Publication.Methodologies = methodologies; return result; }); })); }