コード例 #1
0
        public void MapToDetailRep_HasExpectedBioText_WithValidInput()
        {
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.Equal(_validDbArtist.BioText, result.BioText);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        public void MapToDetailRep_DoesNotReturnNull_WithValidInput()
        {
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.NotNull(result);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void MapToDetailRep_HasNullBioImageId_WithNullInput()
        {
            DbArtist sourceObj = _validDbArtist;

            sourceObj.BioImageId = null;
            ArtistMapper mapper = new ArtistMapper();
            ArtistDetail result = mapper.MapToDetailRep(_validDbArtist);

            Assert.Null(result.BioImageId);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        public void MapToDetailRep_ThrowsNullReferenceException_WithNullInput()
        {
            ArtistMapper mapper = new ArtistMapper();

            Assert.Throws <NullReferenceException>(() => mapper.MapToDetailRep(null));
        }