mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 22:56:25 +00:00
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
using NUnit.Framework;
|
|
|
|
namespace SpotifyAPI.Web.Tests
|
|
{
|
|
[TestFixture]
|
|
public class PPlayableItemConverterTest
|
|
{
|
|
[Test]
|
|
public void PlayableItemConverter_CanSerialize()
|
|
{
|
|
var context = new CurrentlyPlayingContext { Item = new FullTrack() };
|
|
|
|
Assert.DoesNotThrow(() =>
|
|
{
|
|
var serialized = JsonConvert.SerializeObject(context);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task PlayableItemConverter_Reserialize()
|
|
{
|
|
// This has lowercase field names since it's a spotify response
|
|
var fixture = await File.ReadAllTextAsync(
|
|
Path.Join(TestContext.CurrentContext.TestDirectory, "Fixtures/full_playlist_response.json")
|
|
);
|
|
|
|
var fullPlaylist = JsonConvert.DeserializeObject<FullPlaylist>(fixture);
|
|
// This whill have uppercase field names since we use default JsonConvert settings
|
|
var serialized = JsonConvert.SerializeObject(fullPlaylist);
|
|
|
|
Assert.DoesNotThrow(() =>
|
|
{
|
|
var deserialized = JsonConvert.DeserializeObject<FullPlaylist>(serialized);
|
|
});
|
|
}
|
|
}
|
|
}
|