Esempio n. 1
0
        public override async Task <bool> TrackUpdateAsync(Track track)
        {
            // Map track to db model
            DBModels.Track dbTrack = autoMapper.Map <DBModels.Track>(track);

            // Update track
            int recordsChanged;

            try { recordsChanged = await repository.TrackUpdateAsync(dbTrack); }
            catch { recordsChanged = 0; }
            return(recordsChanged > -1);
        }
Esempio n. 2
0
        public override async Task <bool> TrackAddAsync(Track track)
        {
            // Map track to db model
            DBModels.Track dbTrack = autoMapper.Map <DBModels.Track>(track);

            // Add new track to database
            int recordsChanged;

            try { recordsChanged = await repository.TrackAddAsync(dbTrack); }
            catch { recordsChanged = 0; }
            return(recordsChanged > 0);
        }
Esempio n. 3
0
        public async Task TrackGetByIDAsync_ReturnsItem()
        {
            DBModels.Track dbTrack = new DBModels.Track {
                AlbumID = 1, TrackID = 1
            };
            Mock <MusicDemoRepository> mockRepo = new Mock <MusicDemoRepository>(null);

            mockRepo.Setup(m => m.TrackGetByIDAsync(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(dbTrack);

            DBBackendProvider backend = new DBBackendProvider(autoMapper, mockRepo.Object);
            Track             track   = await backend.TrackGetByIDAsync(1, 1);

            Assert.IsNotNull(track);
            Assert.AreEqual(1, track.AlbumID);
            Assert.AreEqual(1, track.TrackID);
        }