private void SubmitName_Click(object sender, RoutedEventArgs e) { PlaylistViewModel PlaylistVM = new PlaylistViewModel(); if (UserSettings.globalCurrentAccount != null) { PlaylistVM.AddPlaylist(new Playlist(UserSettings.globalCurrentAccount.UserId, BassTrackVM.TracksList, this.PlaylistName.Text), SendToServer.IsChecked ?? false); } else { PlaylistVM.AddPlaylist(new Playlist(0, BassTrackVM.TracksList, this.PlaylistName.Text), SendToServer.IsChecked ?? false); } Close(); }
public static void AddFirstPlaylist() { UploadList uploadList; TemplateList templateList; PlaylistList playlistList; MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(BaseSettings.UserSuffix, BaseSettings.SubFolder, out uploadList, out templateList, out playlistList); mainWindowViewModel.TabNo = 2; PlaylistViewModel playlistViewModel = (PlaylistViewModel)mainWindowViewModel.CurrentViewModel; playlistViewModel.AddPlaylist(new Playlist(BasicTests.testPlaylistName, BasicTests.testPlaylistId)); Assert.IsTrue(uploadList.UploadCount == 0); Assert.IsTrue(templateList.TemplateCount == 0); Assert.IsTrue(playlistList.PlaylistCount == 1); Playlist playlist = playlistList.GetPlaylist(0); Assert.IsTrue(playlist.Name == BasicTests.testPlaylistName); Assert.IsTrue(playlist.PlaylistId == BasicTests.testPlaylistId); uploadList = null; templateList = null; playlistList = null; mainWindowViewModel = null; Assert.IsTrue(!File.Exists(Path.Combine(BaseSettings.StorageFolder, "uploads.json"))); Assert.IsTrue(!File.Exists(Path.Combine(BaseSettings.StorageFolder, "uploadlist.json"))); Assert.IsTrue(!File.Exists(Path.Combine(BaseSettings.StorageFolder, "templatelist.json"))); Assert.IsTrue(File.Exists(Path.Combine(BaseSettings.StorageFolder, "playlistlist.json"))); JArray jArray = (JArray)((JObject)JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(BaseSettings.StorageFolder, "playlistlist.json"))))["playlists"]; Assert.IsTrue(jArray.Count == 1); bool found = false; int playistCount = 0; foreach (JObject jsonPlaylist in jArray.SelectTokens("$.[*]")) { playistCount++; string name = jsonPlaylist["name"].Value <string>(); string playlistId = jsonPlaylist["playlistId"].Value <string>(); if (name == BasicTests.testPlaylistName) { found = true; } Assert.IsTrue(name == BasicTests.testPlaylistName); Assert.IsTrue(playlistId == BasicTests.testPlaylistId); } Assert.IsTrue(playistCount == 1); Assert.IsTrue(found); }