Example #1
0
        public void TestCompare(ScanCompareType compareType, long value1, long value2, byte[] data, bool expectedResult, ScanResult expectedScanResult)
        {
            var sut = new LongMemoryComparer(compareType, value1, value2);

            Check.That(sut.Compare(data, 0, out var scanResult)).IsEqualTo(expectedResult);
            Check.That(scanResult).IsEqualTo(expectedScanResult);
            if (scanResult != null)
            {
                Check.That(scanResult).IsInstanceOf <LongScanResult>();
            }
        }
Example #2
0
        public void TestCompareInvalidCompareTypeThrows(ScanCompareType compareType)
        {
            var sut = new LongMemoryComparer(compareType, 0L, 0L);

            Check.ThatCode(() => sut.Compare(BitConverter.GetBytes(0L), 0, out _)).Throws <InvalidCompareTypeException>();
        }
Example #3
0
        public void TestCompareWithPreviousThrows()
        {
            var sut = new LongMemoryComparer(ScanCompareType.Unknown, 0L, 0L);

            Check.ThatCode(() => sut.Compare(BitConverter.GetBytes(0L), 0, new LongScanResult(0L), out _)).Throws <InvalidCompareTypeException>();
        }
Example #4
0
        public void TestCompareInvalidDataThrows(byte[] data, int index, Type expectedExceptionType)
        {
            var sut = new LongMemoryComparer(ScanCompareType.Equal, 0L, 0L);

            Check.ThatCode(() => sut.Compare(data, index, out _)).ThrowsType(expectedExceptionType);
        }