Example #1
0
        public void Base64CodecDecodeCall_WithNullOrWhiteSpParam_ShouldThrow()
        {
            // Arrange
            var base64Codec = new Base64Codec();

            // Act
            var encodedText = base64Codec.Decode(" ");

            // should have thrown
        }
Example #2
0
        public void Roundtrip(int length)
        {
            var original = new byte[length];

            new Random(1337).NextBytes(original);

            var encoded = Codec.Encode(original);
            var decoded = Codec.Decode(encoded);

            Assert.Equal(original, decoded);
        }
Example #3
0
        public void Base64Codec_GivenBase64StringDecodeMethodWorks_ShouldPass()
        {
            // Arrange
            var    base64Codec  = new Base64Codec();
            string expectedText = "Hello .NET Nuts and bolts";

            // Act
            var encodedText = base64Codec.Encode(expectedText);
            var decodedText = base64Codec.Decode(encodedText);

            // Assert
            Assert.AreEqual(decodedText, expectedText);
        }
Example #4
0
        public void RoundtripNoPadding(int length)
        {
            var noPaddingCodec = new Base64Codec(false);

            var original = new byte[length];

            new Random(1337).NextBytes(original);

            var encoded = noPaddingCodec.Encode(original);

            Assert.False(encoded.EndsWith('='));

            var decoded = noPaddingCodec.Decode(encoded);

            Assert.Equal(original, decoded);
        }
            public void HttpClientAuthCfg_AddBasicAuthHeaders_HasAddedBasicAuthorizationHdrs_ShouldPass()
            {
                // Arrange
                var httpClient      = new HttpClient();
                var base64codec     = new Base64Codec();
                var newCfgratorInst = new HttpClientAuthorizeConfigurator(base64codec);

                // Act
                var result = newCfgratorInst.AddBasicAuthorizationHeaderValue(
                    httpClient, "userName", "password");

                var encodedAuthValue = httpClient.DefaultRequestHeaders.Authorization;
                var decodedAuthKey   = base64codec.Decode(encodedAuthValue.Parameter);
                var scheme           = encodedAuthValue.Scheme;

                // Assert
                Assert.IsTrue(result);
                Assert.AreEqual("userName:password", decodedAuthKey);
                Assert.AreEqual("Basic", scheme);
            }
        public void DecodeFromString()
        {
            string result = _codec.Decode(TARGET);

            Assert.Equal(SOURCE, result);
        }
 public void Mine()
 {
     _ = _mine.Decode(_encoded);
 }