コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }