public override async Task <Track> TrackGetByIDAsync(int albumID, int trackID) { // Get track from database DBModels.Track track; try { track = await repository.TrackGetByIDAsync(albumID, trackID); } catch { track = null; } // Return desired track return(autoMapper.Map <Track>(track)); }
public async Task TrackGetByIDAsync_ReturnsItem() { Mock <DbSet <Track> > mockTracks = GetMockTracks(); Mock <MusicDemoDbContext> mockContext = new Mock <MusicDemoDbContext>(); mockContext.Setup(m => m.Tracks).Returns(mockTracks.Object); MusicDemoRepository repo = new MusicDemoRepository(mockContext.Object); Track track = await repo.TrackGetByIDAsync(1, 1); Assert.IsNotNull(track); Assert.AreEqual(1, track.AlbumID); Assert.AreEqual(1, track.TrackID); }