mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 22:56:25 +00:00
0391371a8c
* Bump NUnit from 3.13.3 to 4.0.0 Bumps [NUnit](https://github.com/nunit/nunit) from 3.13.3 to 4.0.0. - [Release notes](https://github.com/nunit/nunit/releases) - [Changelog](https://github.com/nunit/nunit/blob/master/CHANGES.md) - [Commits](https://github.com/nunit/nunit/compare/v3.13.3...v4.0.0) --- updated-dependencies: - dependency-name: NUnit dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * update tests to nunit 4.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jonas Dellinger <jonas@dellinger.dev>
60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using System;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using SpotifyAPI.Web.Http;
|
|
|
|
namespace SpotifyAPI.Web
|
|
{
|
|
[TestFixture]
|
|
public class SpotifyClientConfigTest
|
|
{
|
|
[Test]
|
|
public void CreateDefault_CorrectDefaults()
|
|
{
|
|
var defaultConfig = SpotifyClientConfig.CreateDefault();
|
|
|
|
Assert.That(defaultConfig.DefaultPaginator, Is.InstanceOf(typeof(SimplePaginator)));
|
|
Assert.That(defaultConfig.HTTPClient, Is.InstanceOf(typeof(NetHttpClient)));
|
|
Assert.That(defaultConfig.JSONSerializer, Is.InstanceOf(typeof(NewtonsoftJSONSerializer)));
|
|
Assert.That(SpotifyUrls.APIV1, Is.EqualTo(defaultConfig.BaseAddress));
|
|
Assert.That(null, Is.EqualTo(defaultConfig.Authenticator));
|
|
Assert.That(null, Is.EqualTo(defaultConfig.HTTPLogger));
|
|
Assert.That(null, Is.EqualTo(defaultConfig.RetryHandler));
|
|
}
|
|
|
|
[Test]
|
|
public void CreateDefault_CorrectDefaultsWithToken()
|
|
{
|
|
var token = "my-token";
|
|
var tokenType = "Bearer";
|
|
|
|
var defaultConfig = SpotifyClientConfig.CreateDefault(token, tokenType);
|
|
|
|
Assert.That(defaultConfig.DefaultPaginator, Is.InstanceOf(typeof(SimplePaginator)));
|
|
Assert.That(defaultConfig.HTTPClient, Is.InstanceOf(typeof(NetHttpClient)));
|
|
Assert.That(defaultConfig.JSONSerializer, Is.InstanceOf(typeof(NewtonsoftJSONSerializer)));
|
|
Assert.That(SpotifyUrls.APIV1, Is.EqualTo(defaultConfig.BaseAddress));
|
|
Assert.That(null, Is.EqualTo(defaultConfig.HTTPLogger));
|
|
Assert.That(null, Is.EqualTo(defaultConfig.RetryHandler));
|
|
|
|
Assert.That(defaultConfig.Authenticator, Is.InstanceOf(typeof(TokenAuthenticator)));
|
|
|
|
var tokenHeaderAuth = defaultConfig.Authenticator as TokenAuthenticator;
|
|
Assert.That(token, Is.EqualTo(tokenHeaderAuth.Token));
|
|
Assert.That(tokenType, Is.EqualTo(tokenHeaderAuth.TokenType));
|
|
}
|
|
|
|
[Test]
|
|
public void WithToken_CreatesNewInstance()
|
|
{
|
|
var token = "my-token";
|
|
var defaultConfig = SpotifyClientConfig.CreateDefault();
|
|
var tokenConfig = defaultConfig.WithToken(token);
|
|
|
|
Assert.That(token, Is.EqualTo((tokenConfig.Authenticator as TokenAuthenticator).Token));
|
|
Assert.That(defaultConfig, Is.Not.EqualTo(tokenConfig));
|
|
Assert.That(null, Is.EqualTo(defaultConfig.Authenticator));
|
|
}
|
|
}
|
|
}
|