예제 #1
0
        // 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();
        }
예제 #2
0
        public void Query_Test_ParsedXmlHasNoNullValuesGivenValidInput()
        {
            var metadataFile = GetMetadataFile();

            var response = GracenoteAPI.Query(metadataFile);

            Assert.IsFalse(HasNullValues(response));
        }
예제 #3
0
        public void Query_Test_ReturnsNonNullResultGivenValidInput()
        {
            var metadataFile = GetMetadataFile();

            var response = GracenoteAPI.Query(metadataFile);

            Assert.IsNotNull(response);
        }
예제 #4
0
        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));
        }
예제 #5
0
        public void Query_Test_ThrowsNullReferenceExceptionGivenNullInput()
        {
            MetadataFile nullFile = null;

            Assert.ThrowsException <NullReferenceException>(() => GracenoteAPI.Query(nullFile));
        }