public void TestCompare(ScanCompareType compareType, float value1, float value2, byte[] data, bool expectedResult, ScanResult expectedScanResult) { var sut = new FloatMemoryComparer(compareType, ScanRoundMode.Normal, 1, value1, value2, BitConverter); Check.That(sut.Compare(data, 0, out var scanResult)).IsEqualTo(expectedResult); Check.That(scanResult).IsEqualTo(expectedScanResult); if (scanResult != null) { Check.That(scanResult).IsInstanceOf <FloatScanResult>(); } }
public void TestCompareInvalidCompareTypeThrows(ScanCompareType compareType) { var sut = new FloatMemoryComparer(compareType, ScanRoundMode.Normal, 1, 0.0f, 0.0f, BitConverter); Check.ThatCode(() => sut.Compare(BitConverter.GetBytes(0.0f), 0, out _)).Throws <InvalidCompareTypeException>(); }
public void TestCompareWithPreviousThrows() { var sut = new FloatMemoryComparer(ScanCompareType.Unknown, ScanRoundMode.Normal, 1, 0, 0, BitConverter); Check.ThatCode(() => sut.Compare(BitConverter.GetBytes(0.0f), 0, new FloatScanResult(0.0f), out _)).Throws <InvalidCompareTypeException>(); }
public void TestCompareInvalidDataThrows(byte[] data, int index, Type expectedExceptionType) { var sut = new FloatMemoryComparer(ScanCompareType.Unknown, ScanRoundMode.Normal, 1, 0.0f, 0.0f, BitConverter); Check.ThatCode(() => sut.Compare(data, index, out _)).ThrowsType(expectedExceptionType); }