mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-25 15:36:26 +00:00
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using NUnit.Framework;
|
|
using SpotifyAPI.Local.Models;
|
|
using SpotifyAPI.Local.Enums;
|
|
using System;
|
|
|
|
namespace SpotifyAPI.Tests
|
|
{
|
|
[TestFixture]
|
|
public class SpotifyUriTest
|
|
{
|
|
[Test]
|
|
public void ShouldThrowArgumentExceptionForInvalidUri()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => SpotifyUri.Parse("asdafadfgsrsegqejfa"));
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldCorrectlyParseTrackUri()
|
|
{
|
|
string testUri = "spotify:track:3QOruXa2lvqIFvOOa2rYyJ";
|
|
SpotifyUri uri = SpotifyUri.Parse(testUri);
|
|
|
|
Assert.AreEqual(uri.Base, "spotify");
|
|
|
|
Assert.AreEqual(uri.Type, UriType.track);
|
|
Assert.AreEqual(uri.Id, "3QOruXa2lvqIFvOOa2rYyJ");
|
|
Assert.AreEqual(uri.ToString(), testUri);
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldCorrectlyParsePlaylistUri()
|
|
{
|
|
string testUri = "spotify:user:spotifycharts:playlist:37i9dQZEVXbMDoHDwVN2tF";
|
|
SpotifyUri uri = SpotifyUri.Parse(testUri);
|
|
|
|
Assert.AreEqual(uri.Base, "spotify");
|
|
|
|
Assert.AreEqual(uri.Type, UriType.playlist);
|
|
Assert.AreEqual(uri.Id, "37i9dQZEVXbMDoHDwVN2tF");
|
|
|
|
Assert.AreEqual(uri.GetUriPropValue(UriType.user), "spotifycharts");
|
|
Assert.AreEqual(uri.ToString(), testUri);
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldHandleNotExistingUriProperty()
|
|
{
|
|
string testUri = "spotify:track:3QOruXa2lvqIFvOOa2rYyJ";
|
|
SpotifyUri uri = SpotifyUri.Parse(testUri);
|
|
Assert.DoesNotThrow(() => uri.GetUriPropValue(UriType.user));
|
|
Assert.IsNull(uri.GetUriPropValue(UriType.user));
|
|
}
|
|
}
|
|
} |