Ejemplo n.º 1
0
        public override async Task <bool> AlbumDeleteByIDAsync(int artistID, int albumID)
        {
            // Delete album from database
            int recordsChanged;

            try { recordsChanged = await repository.AlbumDeleteByIDAsync(artistID, albumID); }
            catch { recordsChanged = 0; }
            return(recordsChanged > 0);
        }
Ejemplo n.º 2
0
        public async Task AlbumDeleteByIDAsync_DeletesItem()
        {
            Mock <DbSet <Album> >     mockAlbums  = GetMockAlbums();
            Mock <MusicDemoDbContext> mockContext = new Mock <MusicDemoDbContext>();

            mockContext.Setup(m => m.Albums).Returns(mockAlbums.Object);

            MusicDemoRepository repo = new MusicDemoRepository(mockContext.Object);
            await repo.AlbumDeleteByIDAsync(1, 1);

            mockAlbums.Verify(m => m.Remove(It.Is <Album>(a => a.AlbumID == 1)), Times.Once());
            mockContext.Verify(m => m.SaveChangesAsync(), Times.Once());
        }