public void ToHexChars_Regularly_ShouldReturnExpectedOutput(string text, string hexString) { var bytes = System.Text.Encoding.UTF8.GetBytes(text); Span <byte> outputChars = stackalloc byte[hexString.Length]; Hexadecimal.ToHexChars(bytes, outputChars); var outputString = System.Text.Encoding.UTF8.GetString(outputChars); Assert.Equal(hexString, outputString); }
public void FromHexChars_AfterToHexChars_ShouldReturnOriginalInput(string text, string hexString) { var bytes = System.Text.Encoding.UTF8.GetBytes(text); Span <byte> outputChars = stackalloc byte[hexString.Length]; Hexadecimal.ToHexChars(bytes, outputChars); Span <byte> decodedBytes = stackalloc byte[bytes.Length]; Hexadecimal.FromHexChars(outputChars, decodedBytes); var originalString = System.Text.Encoding.UTF8.GetString(decodedBytes); Assert.Equal(text, originalString); }