public static string Shrink(this Guid source)
        {
            Invariant.IsNotEmpty(source, nameof(source));

            var base64  = Convert.ToBase64String(source.ToByteArray());
            var encoded = base64.Replace("/", "_").Replace("+", "-");

            return(encoded.Substring(0, SHRUNKEN_GUID_LENGTH));
        }
예제 #2
0
        public void IsNotEmptyOfString_When_Argument_Is_Empty_String_Should_Throw_ArgumentException()
        {
            var ex = Assert.Throws <ArgumentException>(() => Invariant.IsNotEmpty(string.Empty, PARAMETER_NAME));

            Assert.AreEqual($"Argument '{PARAMETER_NAME}' must not be empty.", ex.Message);
        }
예제 #3
0
 public void IsNotEmptyOfString_When_Argument_Is_Null_Should_Not_Throw()
 {
     Assert.DoesNotThrow(() => Invariant.IsNotEmpty(null, PARAMETER_NAME));
 }
예제 #4
0
 public void IsNotEmptyOfGuid_When_Argument_Is_Not_Empty_Guid_Should_Not_Throw()
 {
     Assert.DoesNotThrow(
         () => Invariant.IsNotEmpty(new Guid("B51ADF9B-077C-42F3-91D0-5E97E6B25B9D"), PARAMETER_NAME));
 }