public void Base64_ToB64Url_Test() { var rnd = new CryptoRandom(); Parallel.For(1, 5000, i => { var byteArray = rnd.NextBytes(i); var offset = 0; var count = Math.Max(i, i - rnd.Next(10)); var byteSegment = new ArraySegment<byte>(byteArray, offset, count); var b64url = byteSegment.ToB64Url(); var b64 = byteSegment.ToB64(); Assert.IsTrue(b64url + b64[b64.Length - 1] == b64); Assert.IsTrue(Enumerable.SequenceEqual(byteSegment, b64url.FromB64Url())); }); }// Base64_ToB64Url_Test()