Example #1
0
        public void EncodeWithPadding_AlphabetIsAnEmptyString_ThrowsArgumentNullException()
        {
            var exception = Assert.Throws <ArgumentException>(() => Bijective.Encode(1, "", 10));

            Assert.Contains("alphabet must not be an empty string", exception.Message);
        }
Example #2
0
        public void EncodeWithPadding_PaddingLessThanZero_ThrowsArgumentOutOfRangeException()
        {
            var exception = Assert.Throws <ArgumentOutOfRangeException>(() => Bijective.Encode(1, Alphabet.Base62, -1));

            Assert.Contains("padding must be greater than or equal to zero", exception.Message);
        }
Example #3
0
        public void EncodeWithPadding_AlphabetIsNull_ThrowsArgumentNullException()
        {
            var exception = Assert.Throws <ArgumentNullException>(() => Bijective.Encode(1, null, 10));

            Assert.Contains("alphabet must not be null", exception.Message);
        }
Example #4
0
        public void Encode_ValueLessThanZero_ThrowsArgumentOutOfRangeException()
        {
            var exception = Assert.Throws <ArgumentOutOfRangeException>(() => Bijective.Encode(-1, Alphabet.Base62));

            Assert.Contains("value must be greater than or equal to zero", exception.Message);
        }
Example #5
0
 public void EncodeWithPadding(string expected, int value, string alphabet, int padding)
 {
     Assert.Equal(expected, Bijective.Encode(value, alphabet, padding));
 }
Example #6
0
 public void Encode(string result, int value, string alphabet)
 {
     Assert.Equal(result, Bijective.Encode(value, alphabet));
 }
Example #7
0
        public string GetShortUri(int databaseId)
        {
            var shortUri = Bijective.Encode(databaseId);

            return(shortUri);
        }