// Break this apart and move functionality to other classes if it seems fitting private async void CheckMetadataButton_Click(object sender, RoutedEventArgs e) { headerTextBlock.Text = "Checking for updated metadata, please wait..."; StartBusyIndicator(); // populates the API response field for each metadata file that is flagged for update foreach (var file in userSelectedFiles.Where(f => f.MetadataFile.CheckForUpdates == true)) { file.MetadataFile.Response = await GracenoteAPI.QueryAsync(file.MetadataFile); } // filters all userSelectedFiles to only those where an update is needed var systemFilesPendingUpdates = userSelectedFiles.Where(f => f.MetadataFile.IsUpdateNeeded() == true); // checks to see if there are any updates needed bool updateNeeded = systemFilesPendingUpdates.Any(); if (updateNeeded) { var metadataFilesPendingUpdates = systemFilesPendingUpdates.Select(f => f.MetadataFile).Cast <MetadataFile>().ToList(); metadataFilesPendingUpdates.ForEach(f => f.PopulateUpdateList()); _allUpdates = ExtractUpdates(metadataFilesPendingUpdates); var updaterWindow = new UpdaterWindow(_allUpdates); } else { headerTextBlock.Text = "All songs are up to date."; } StopBusyIndicator(); }
public void Query_Test_ParsedXmlHasNoNullValuesGivenValidInput() { var metadataFile = GetMetadataFile(); var response = GracenoteAPI.Query(metadataFile); Assert.IsFalse(HasNullValues(response)); }
public void Query_Test_ReturnsNonNullResultGivenValidInput() { var metadataFile = GetMetadataFile(); var response = GracenoteAPI.Query(metadataFile); Assert.IsNotNull(response); }
public void Query_Test_ThrowsNullReferenceExceptionGivenEmptyFieldsInInput() { var metadataFile = GetMetadataFile(); metadataFile.Artist = string.Empty; metadataFile.Album = string.Empty; metadataFile.Title = string.Empty; Assert.ThrowsException <NullReferenceException>(() => GracenoteAPI.Query(metadataFile)); }
public void Query_Test_ThrowsNullReferenceExceptionGivenNullInput() { MetadataFile nullFile = null; Assert.ThrowsException <NullReferenceException>(() => GracenoteAPI.Query(nullFile)); }