コード例 #1
0
        [TestInitialize] // runs this method before every test
        public void TestInitialize()
        {
            var options = new DbContextOptionsBuilder <zackalbumsContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            _context = new zackalbumsContext(options);

            //creating mock data
            var artist = new Artists
            {
                ArtistId   = 100,
                ArtistName = "System Of A Down"
            };

            albums.Add(new Albums
            {
                AlbumId     = 10,
                AlbumArt    = "",
                AlbumName   = "System Of A Down",
                Artist      = artist,
                ReleaseYear = 1998,
                Rating      = 6
            });

            albums.Add(new Albums
            {
                AlbumId     = 20,
                AlbumArt    = "",
                AlbumName   = "Toxicity",
                Artist      = artist,
                ReleaseYear = 2001,
                Rating      = 7
            });

            albums.Add(new Albums
            {
                AlbumId     = 30,
                AlbumArt    = "",
                AlbumName   = "Steal This Album!",
                Artist      = artist,
                ReleaseYear = 2002,
                Rating      = 9
            });

            foreach (var a in albums)
            {
                _context.Add(a);
            }
            _context.SaveChanges();

            albumsController = new AlbumsController(_context);
        }
コード例 #2
0
 public ArtistsController(zackalbumsContext context)
 {
     _context = context;
 }
コード例 #3
0
 public SongsController(zackalbumsContext context)
 {
     _context = context;
 }