Spotify.NET/SpotifyAPI.Web.Tests/UtilTests/Base64UtilTest.cs
dependabot[bot] 0391371a8c
Bump NUnit from 3.13.3 to 4.0.0 (#922)
* 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>
2024-02-10 11:41:47 +01:00

44 lines
1.0 KiB
C#

using System.Text;
using NUnit.Framework;
namespace SpotifyAPI.Web.Tests
{
[TestFixture]
public class Base64UtilTest
{
[Test]
public void Base64UrlDecode_Works()
{
var encoded = "SGVsbG9Xb3JsZA";
Assert.That("HelloWorld", Is.EqualTo(Encoding.UTF8.GetString(Base64Util.UrlDecode(encoded))));
}
[Test]
public void Base64UrlEncode_Works()
{
var decoded = "HelloWorld";
Assert.That("SGVsbG9Xb3JsZA", Is.EqualTo(Base64Util.UrlEncode(Encoding.UTF8.GetBytes(decoded))));
}
[Test]
public void Base64UrlEncode_WorksSpecialChars()
{
var bytes = new byte[] { 0x04, 0x9f, 0x9c, 0xff, 0x3f, 0x0a };
// normal base64: BJ+c/z8K
Assert.That("BJ-c_z8K", Is.EqualTo(Base64Util.UrlEncode(bytes)));
}
[Test]
public void Base64UrlDecode_WorksSpecialChars()
{
var bytes = new byte[] { 0x04, 0x9f, 0x9c, 0xff, 0x3f, 0x0a };
// normal base64: BJ+c/z8K
Assert.That(bytes, Is.EqualTo(Base64Util.UrlDecode("BJ-c_z8K")));
}
}
}