Пример #1
0
        public override async Task <List <Artist> > ArtistGetAllAsync()
        {
            // Get artists from database
            List <DBModels.Artist> artists;

            try { artists = await repository.ArtistGetAllAsync(); }
            catch { artists = null; }

            // Return all artists in database
            return(autoMapper.Map <List <Artist> >(artists));
        }
Пример #2
0
        public async Task ArtistGetAllAsync_SortsByName()
        {
            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);
            List <Artist>       artists = await repo.ArtistGetAllAsync();

            Assert.AreEqual(2, artists.Count);
            Assert.AreEqual("Foxxx", artists[0].Name);
            Assert.AreEqual("Kaskade", artists[1].Name);
        }