예제 #1
0
        public void TestCreatingPlaylistFile()
        {
            EZPlaylist playlist = new EZPlaylist("My Awesome Playlist");
            MediaLibrary lib = new MediaLibrary();
            if (lib.Songs.Count > 0)
            {
                Song song = lib.Songs[0];
                SongInfo si = new SongInfo(song.Artist.Name, song.Album.Name, song.Name, song.Duration, song.TrackNumber);
                playlist.Add(si);

                playlist.SavePlaylist();
                playlist.Clear();

                playlist = new EZPlaylist();
                playlist.ReadFromFile("My Awesome Playlist");
                Assert.IsTrue(playlist.Contains(si));
                Assert.IsTrue(playlist.Count == 1);
                Assert.IsTrue(playlist.Name == "My Awesome Playlist");
            }
            else
            {
                Assert.Fail("Can't test adding a song because there are no songs to add.");
            }
        }
예제 #2
0
        public void TestCreatingPlaylistOfEntireLibrary()
        {
            EZPlaylist playlist = new EZPlaylist("My Awesome Playlist");
            MediaLibrary lib = new MediaLibrary();
            List<SongInfo> SIlist = new List<SongInfo>();
            if (lib.Songs.Count > 0)
            {
                foreach (Song song in lib.Songs)
                {
                    SongInfo si = new SongInfo(song.Artist.Name, song.Album.Name, song.Name, song.Duration, song.TrackNumber);
                    playlist.Add(si);
                    SIlist.Add(si);
                }

                playlist.SavePlaylist();
                playlist.Clear();

                playlist = new EZPlaylist();
                playlist.ReadFromFile("My Awesome Playlist");
                foreach (SongInfo si in SIlist)
                {
                    Assert.IsTrue(playlist.Contains(si));
                }
                Assert.IsTrue(playlist.Count == SIlist.Count);
                Assert.IsTrue(playlist.Name == "My Awesome Playlist");
            }
            else
            {
                Assert.Fail("Can't test adding a song because there are no songs to add.");
            }
        }
예제 #3
0
        public void TestDeletingPlaylistFile()
        {
            EZPlaylist playlist = new EZPlaylist("YUP");
            playlist.SavePlaylist(); //creates "YUP.xml"
            playlist.Clear();

            playlist.ReadFromFile("YUP"); //reading from "YUP.xml" confirming that it exists
            playlist.DeletePlaylist();

            playlist = new EZPlaylist("NOPE");
            playlist.ReadFromFile("YUP"); //If "YUP" exists, playlist should be named "YUP"
            Assert.IsTrue(playlist.Name == "NOPE"); //Since YUP does not exist, playlist's name is still NOPE
        }