Example #1
0
        public void CrockfordBase32Encoding_Encode_ShouldReturnExpectedResult(TestDatum datum)
        {
            var number   = ulong.Parse(datum.Number);
            var expected = datum.EncodedString;

            var actual = new CrockfordBase32Encoding().Encode(number, false);

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void CrockfordBase32Encoding_Encode_ShouldReturnExpectedResultWithCheckDigit(TestDatum datum)
        {
            var number     = ulong.Parse(datum.Number);
            var expected   = datum.EncodedString;
            var checkDigit = datum.CheckDigit;

            var actual = new CrockfordBase32Encoding().Encode(number, true);

            Assert.Equal(expected + checkDigit, actual);
        }
Example #3
0
        public void CrockfordBase32Encoding_Decode_ShouldReturnNullForIncorrectCheckDigit(TestDatum datum)
        {
            var encodedString = datum.EncodedString;
            var checkDigit    = datum.CheckDigit;

            checkDigit = checkDigit.Equals("a", StringComparison.OrdinalIgnoreCase) ? "b" : "a";

            var actual = new CrockfordBase32Encoding().Decode(encodedString + checkDigit, true);

            Assert.Null(actual);
        }
Example #4
0
        public void CrockfordBase32Encoding_Decode_ShouldReturnNullForInvalidCheckDigit(TestDatum datum)
        {
            var encodedString = datum.EncodedString;

            var actual = new CrockfordBase32Encoding().Decode(encodedString + '#', true);

            Assert.Null(actual);
        }