Exemplo n.º 1
0
        public void TestPlaylistBasics()
        {
            BmpSong song = LoadTestSong();

            Assert.IsNull(song.Id);

            using (BmpCoffer test = this.CreateCofferManager())
            {
                test.SaveSong(song);
                Assert.IsNotNull(song.Id);

                IPlaylist playlist = test.CreatePlaylist(PLAYLIST_NAME);
                Assert.IsNotNull(playlist);
                Assert.IsTrue(playlist is BmpPlaylistDecorator);
                Assert.AreEqual(PLAYLIST_NAME, playlist.GetName());

                // Internal things...
                BmpPlaylist backingData = ((BmpPlaylistDecorator)playlist).GetBmpPlaylist();
                Assert.IsNull(backingData.Id);

                playlist.Add(song);

                test.SavePlaylist(playlist);
                Assert.IsNotNull(backingData.Id);

                IPlaylist result = test.GetPlaylist(PLAYLIST_NAME);
                Assert.IsNotNull(result);
                Assert.AreEqual(backingData.Id, ((BmpPlaylistDecorator)playlist).GetBmpPlaylist().Id);
            }
        }
Exemplo n.º 2
0
        public void TestSerialization()
        {
            string      playlistName = "Test Playlist";
            ObjectId    playlistId   = ObjectId.NewObjectId();
            BmpPlaylist test         = new BmpPlaylist()
            {
                Name  = playlistName,
                Songs = new List <BmpSong>(),
                Id    = playlistId
            };

            BmpPlaylist saved;

            using (var dbi = this.CreateDatabase())
            {
                var collection = dbi.GetCollection <BmpPlaylist>(Constants.PLAYLIST_COL_NAME);
                collection.Insert(test);

                saved = collection.Query()
                        .Include(x => x.Songs)
                        .Where(x => x.Id.Equals(playlistId))
                        .First();
            }

            Assert.IsNotNull(saved);
            Assert.AreEqual(playlistName, saved.Name);
            Assert.AreEqual(playlistId, saved.Id);
            Assert.IsNotNull(saved.Songs);
            Assert.AreEqual(0, saved.Songs.Count);
        }
Exemplo n.º 3
0
        private static BmpPlaylistDecorator CreateTestPlaylist()
        {
            BmpPlaylist decorateMe = new BmpPlaylist()
            {
                Name  = TEST_PLAYLIST_NAME,
                Id    = null,
                Songs = new List <BmpSong>()
            };

            return(new BmpPlaylistDecorator(decorateMe));
        }