private static void HexAssertValid(this string thisObj, int sizeInBits) { thisObj.NonEmptyAssertValid(); (sizeInBits % 8).Should().Be(0, $"sizeInBits should be divisible by 8 but sizeInBits is {sizeInBits}"); var numHexChars = sizeInBits / 8 * 2; var because = $"String should be {numHexChars} hex digits ({sizeInBits}-bits) but the actual value is `{thisObj}' (length: {thisObj.Length})"; thisObj.Length.Should().Be(numHexChars, because); // 2 hex chars per byte TraceContext.IsHex(thisObj).Should().BeTrue(because); }