Example #1
0
        public void FromBase32String(string expected, string input)
        {
            byte[] expectedBytes = Encoding.ASCII.GetBytes(expected);
            byte[] actual        = Base32Converter.FromBase32String(input);

            Assert.Equal(BitConverter.ToString(expectedBytes), BitConverter.ToString(actual));
        }
Example #2
0
        public void ToBase32String(string input, string expected)
        {
            byte[] bytes  = Encoding.ASCII.GetBytes(input);
            string actual = Base32Converter.ToBase32String(bytes);

            Assert.Equal(expected, actual);
        }
Example #3
0
        public void Base32RoundTrip()
        {
            var input = new byte[4096];

            new Random().NextBytes(input);

            var base32 = Base32Converter.ToBase32String(input);
            var output = Base32Converter.FromBase32String(base32);

            Assert.Equal(input, output);
        }
Example #4
0
 public void ToBase32String_Null_ShouldThrow()
 {
     Assert.Throws <ArgumentNullException>(() => Base32Converter.ToBase32String(null));
 }
Example #5
0
        public void FromBase32String_InvalidCharacters(char input)
        {
            var exception = Assert.Throws <ArgumentException>(() => Base32Converter.FromBase32String(input + "A"));

            Assert.Contains("'" + input + "'", exception.Message);
        }
Example #6
0
 public void FromBase32String_InvalidLength(string input)
 {
     Assert.Throws <ArgumentException>(() => Base32Converter.FromBase32String(input));
 }