public void ReflectBits_UInt16_InvalidBitLength_Throws() { UInt16 value = 0; foreach (var invalidBitLength in new[] { int.MinValue, short.MinValue, -1, 0, 17, short.MaxValue, int.MaxValue }) { Assert.Equal("bitLength", Assert.Throws <ArgumentOutOfRangeException>(() => value.ReflectBits(invalidBitLength)) .ParamName); } }
public void ReflectBits_UInt16_Works() { UInt16 value = 0x5bc1; var expectedValues = new Dictionary <int, UInt16>() { { 1, 0x0001 }, { 9, 0x0107 }, { 2, 0x0002 }, { 10, 0x020f }, { 3, 0x0004 }, { 11, 0x041e }, { 4, 0x0008 }, { 12, 0x083d }, { 5, 0x0010 }, { 13, 0x107b }, { 6, 0x0020 }, { 14, 0x20f6 }, { 7, 0x0041 }, { 15, 0x41ed }, { 8, 0x0083 }, { 16, 0x83da }, }; foreach (var expectedValue in expectedValues) { Assert.Equal( expectedValue.Value, value.ReflectBits(expectedValue.Key)); } }