Ejemplo n.º 1
0
        public void AddToPlaylistTrackTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context = cRUDTestDBContextProvider.GetContext();
            var track   = new Track {
                TrackId = 1
            };
            var playlist = new Playlist {
                PlaylistId = 1
            };

            context.Add(track);
            context.Add(playlist);
            context.SaveChanges();

            PlaylistTrackBE playlistTrackBE = new PlaylistTrackBE(cRUDTestDBContextProvider);
            TrackBE         trackBE         = new TrackBE(cRUDTestDBContextProvider);
            PlaylistBE      playlistBE      = new PlaylistBE(cRUDTestDBContextProvider);

            trackBE.Load(1);
            playlistBE.Load(1);
            playlistTrackBE.New();
            trackBE.AddToPlaylistTrack(playlistTrackBE);
            playlistBE.AddToPlaylistTrack(playlistTrackBE);
            playlistTrackBE.Save();

            trackBE.Load(1);
            var playlistTrackBECollection = trackBE.GetPlaylistTracks();

            Assert.IsTrue(playlistTrackBECollection.First().PlaylistId == 1);
            Assert.IsTrue(playlistTrackBECollection.First().TrackId == 1);
        }
Ejemplo n.º 2
0
        public void PlaylistTrackCountTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var playlist = new Playlist
            {
                PlaylistId = 1,
                Name       = "TestPlaylistName"
            };
            var track = new Track
            {
                TrackId = 1,
                Name    = "TestTrackName"
            };
            var track2 = new Track
            {
                TrackId = 2,
                Name    = "TestTrackName"
            };
            var playlistTrack = new PlaylistTrack
            {
                PlaylistId = 1,
                TrackId    = 1
            };

            context.Add(playlist);
            context.Add(track);
            context.Add(track2);
            context.Add(playlistTrack);
            context.SaveChanges();

            PlaylistBE playlistBE = new PlaylistBE(cRUDTestDBContextProvider);

            playlistBE.Load(1);
            Assert.IsTrue(playlistBE.PlaylistTrackCount == 1);

            PlaylistTrackBE playlistTrackBE = new PlaylistTrackBE(cRUDTestDBContextProvider);
            TrackBE         trackBE         = new TrackBE(cRUDTestDBContextProvider);

            playlistTrackBE.New();
            trackBE.Load(2);
            playlistBE.AddToPlaylistTrack(playlistTrackBE);
            trackBE.AddToPlaylistTrack(playlistTrackBE);
            playlistTrackBE.Save();

            PlaylistBE playlistBE3 = new PlaylistBE(cRUDTestDBContextProvider);

            playlistBE3.Load(1);
            Assert.IsTrue(playlistBE3.PlaylistTrackCount == 2);
        }