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)); }
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); }
public void IsNotEmptyOfString_When_Argument_Is_Null_Should_Not_Throw() { Assert.DoesNotThrow(() => Invariant.IsNotEmpty(null, PARAMETER_NAME)); }
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)); }