[TestFixture]
public class SafeBase64UrlTests
{
[Test]
public void Encode64Url_Should_Replace_Plus_With_Minus()
{
var str = "+".EncodeBase64Url();
Assert.That(str.Equals("-"),Is.True);
}
[Test]
public void Encode64Url_Should_Replace_ThreePlus_With_ThreeMinus()
{
var str = "+++".EncodeBase64Url();
Assert.That(str.Equals("---"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_Minus_With_Plus()
{
var str = "-".DecodeBase64Url();
Assert.That(str.Equals("+"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_ThreeMinus_With_ThreePlus()
{
var str = "---".DecodeBase64Url();
Assert.That(str.Equals("+++"), Is.True);
}
[Test]
public void Encode64Url_Should_Replace_Slash_With_Underscore()
{
var str = "/".EncodeBase64Url();
Assert.That(str.Equals("_"), Is.True);
}
[Test]
public void Encode64Url_Should_Replace_ThreeSlash_With_ThreeUnderscore()
{
var str = "///".EncodeBase64Url();
Assert.That(str.Equals("___"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_Underscore_With_Slash()
{
var str = "_".DecodeBase64Url();
Assert.That(str.Equals("/"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_ThreeUnderscore_With_ThreeSlash()
{
var str = "___".DecodeBase64Url();
Assert.That(str.Equals("///"), Is.True);
}
[Test]
public void Encode64Url_Should_Replace_Equal_With_Pipe()
{
var str = "=".EncodeBase64Url();
Assert.That(str.Equals("|"), Is.True);
}
[Test]
public void Encode64Url_Should_Replace_ThreeEqual_With_ThreePipe()
{
var str = "===".EncodeBase64Url();
Assert.That(str.Equals("|||"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_Pipe_With_Equal()
{
var str = "|".DecodeBase64Url();
Assert.That(str.Equals("="), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_ThreePipe_With_ThreeEqual()
{
var str = "|||".DecodeBase64Url();
Assert.That(str.Equals("==="), Is.True);
}
[Test]
public void Encode64Url_Should_Replace_EqualSlashPlus_With_MinusUnderscorePipe()
{
var str = "=+/".EncodeBase64Url();
Assert.That(str.Equals("|-_"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_MinusUnderscorePipe_With_EqualSlashPlus()
{
var str = "|-_".DecodeBase64Url();
Assert.That(str.Equals("=+/"), Is.True);
}
[Test]
public void Encode64Url_Should_Replace_EqualSlashPlus_With_MinusUnderscorePipe_With_Alpha_Numeric_Characters()
{
var str = "1A=2b+3C/4d".EncodeBase64Url();
Assert.That(str.Equals("1A|2b-3C_4d"), Is.True);
}
[Test]
public void Decode64Url_Should_Replace_MinusUnderscorePipe_With_EqualSlashPlus_With_Alpha_Numeric_Characters()
{
var str = "1a|2B-3c_4D".DecodeBase64Url();
Assert.That(str.Equals("1a=2B+3c/4D"), Is.True);
}
[Test]
public void Encode64Url_Should_Return_Same_String_When_Empty()
{
var str = string.Empty.EncodeBase64Url();
Assert.That(string.IsNullOrEmpty(str), Is.True);
}
[Test]
public void Decode64Url_Should_Return_Same_String_When_Empty()
{
var str = string.Empty.DecodeBase64Url();
Assert.That(string.IsNullOrEmpty(str), Is.True);
}
[Test]
public void Encode64Url_Should_Return_Same_String_When_Null()
{
string str = null;
str = str.EncodeBase64Url();
Assert.That(string.IsNullOrEmpty(str), Is.True);
}
[Test]
public void Decode64Url_Should_Return_Same_String_When_Null()
{
string str = null;
str = str.DecodeBase64Url();
Assert.That(string.IsNullOrEmpty(str), Is.True);
}
}