Пример #1
0
        public override async Task <Artist> ArtistGetByIDAsync(int artistID)
        {
            // Get artist from database
            DBModels.Artist artist;
            try { artist = await repository.ArtistGetByIDAsync(artistID); }
            catch { artist = null; }

            // Return desired artist
            return(autoMapper.Map <Artist>(artist));
        }
Пример #2
0
        public async Task ArtistGetByIDAsync_ReturnsItem()
        {
            Mock <DbSet <Artist> >    mockArtists = GetMockArtists();
            Mock <MusicDemoDbContext> mockContext = new Mock <MusicDemoDbContext>();

            mockContext.Setup(m => m.Artists).Returns(mockArtists.Object);

            MusicDemoRepository repo = new MusicDemoRepository(mockContext.Object);
            Artist artist            = await repo.ArtistGetByIDAsync(1);

            Assert.IsNotNull(artist);
            Assert.AreEqual(1, artist.ArtistID);
        }