public void Write_UInt64_Throws_When_Buffer_Is_Too_Small() { var chars = new char[1]; var ex = Assert.Throws <ArgumentException>(() => Hexadecimal.Write(0UL, chars)); Assert.Equal("output", ex.ParamName); }
public void Write_UInt64(ulong input, LetterCase letterCase, string expected) { var chars = new char[16]; Hexadecimal.Write(input, chars, letterCase); Assert.Equal(expected, new string(chars)); }
public void Write_Byte(byte input, LetterCase letterCase, string expected) { var chars = new char[2]; Hexadecimal.Write(input, chars, letterCase); Assert.Equal(expected, new string(chars)); }
public void Write_Throws_When_Buffer_Is_Too_Small(int byteCount, int charCount, char?separator) { var chars = new char[charCount]; var ex = Assert.Throws <ArgumentException>(() => Hexadecimal.Write(new byte[byteCount], chars, separator)); Assert.Equal("output", ex.ParamName); }
private static string FormatHexadecimal(ReadOnlyMemory <byte> bytes) { var charLength = bytes.Length * 2; var chars = charLength <= 64 ? stackalloc char[charLength] : new char[charLength]; Hexadecimal.Write(bytes.Span, chars); return(new string(chars)); }
public void Write(byte[] input, LetterCase @case, char?separator, string expected) { var chars = new char[expected.Length]; Hexadecimal.Write(input, chars, separator, @case); var actual = new string(chars); Assert.Equal(expected, actual); }