public void MapToDetailRep_HasExpectedBioText_WithValidInput() { ArtistMapper mapper = new ArtistMapper(); ArtistDetail result = mapper.MapToDetailRep(_validDbArtist); Assert.Equal(_validDbArtist.BioText, result.BioText); }
public async Task <ArtistDetail> GetAsync(int artistId) { var dbartist = await _context.Artists .Include(x => x.ArtistGenres) .ThenInclude(x => x.Genre) .SingleOrDefaultAsync(x => x.Id == artistId); if (dbartist != null) { return(_mapper.MapToDetailRep(dbartist)); } else { return(null); } }
public void MapToDetailRep_DoesNotReturnNull_WithValidInput() { ArtistMapper mapper = new ArtistMapper(); ArtistDetail result = mapper.MapToDetailRep(_validDbArtist); Assert.NotNull(result); }
public void MapToDetailRep_HasExpectedBioImageUrl_WithValidInput() { DbArtist sourceObj = _validDbArtist; sourceObj.BioImageId = 1515; ArtistMapper mapper = new ArtistMapper(); ArtistDetail result = mapper.MapToDetailRep(_validDbArtist); Assert.Equal("/api/image/1515", result.BioImageUrl); }
public void MapToDetailRep_HasNullBioImageId_WithNullInput() { DbArtist sourceObj = _validDbArtist; sourceObj.BioImageId = null; ArtistMapper mapper = new ArtistMapper(); ArtistDetail result = mapper.MapToDetailRep(_validDbArtist); Assert.Null(result.BioImageId); }
public void MapToDetailRep_HasPublishedStatus_WithValidInput(DbPublishedStatus publishedStatusTestCase) { DbArtist sourceObj = _validDbArtist; sourceObj.PublishStatus = publishedStatusTestCase; PublishedStatusEnumMapper statusMapper = new PublishedStatusEnumMapper(); ArtistMapper mapper = new ArtistMapper(); PublishStatus expetedStatus = statusMapper.Map(publishedStatusTestCase); ArtistDetail result = mapper.MapToDetailRep(sourceObj); ICollection <string> dbGenres = _validDbArtist.ArtistGenres.Select(x => x.Genre.Name).ToList(); Assert.Equal(expetedStatus, result.PublishedStatus); }
public void MapToDetailRep_ThrowsNullReferenceException_WithNullInput() { ArtistMapper mapper = new ArtistMapper(); Assert.Throws <NullReferenceException>(() => mapper.MapToDetailRep(null)); }