static async Task Main(string[] args) { try { var token = await SpotifyClient.GetAccessToken(CLIENT_ID, CLIENT_SECRET); try { var client = new SpotifyClient(token); var searchResponse = await client.Search("Coheed & Cambria", new string[] { "track" }); foreach (var track in searchResponse.Tracks.Items) { Console.WriteLine(track.Name); } } catch (HttpRequestException e) { Console.WriteLine($"Error while executing API request: {e.Message}"); } } catch (HttpRequestException e) { Console.WriteLine($"Error while authenticating: {e.Message}"); } catch (Exception e) { Console.WriteLine($"Uncaught error: {e}"); } Console.WriteLine("\nPress any key to exit."); Console.ReadKey(); }
public void GetAccessToken_Should_Throw_ArgumentNullException_When_Code_IsNullOrWhitespace() { //Arrange string code = null; //Act AsyncTestDelegate act = async() => await spotifyClient.GetAccessToken(code); // Assert Assert.That(act, Throws.TypeOf <ArgumentNullException>()); }