public void TestConstructor(ScanCompareType compareType, long value1, long value2) { var sut = new LongMemoryComparer(compareType, value1, value2, BitConverter); Check.That(sut.CompareType).IsEqualTo(compareType); Check.That(sut.ValueSize).IsEqualTo(sizeof(long)); Check.That(sut.Value1).IsOneOf(value1, value2); Check.That(sut.Value2).IsOneOf(value1, value2); }
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>(); } }
public void TestConstructor(ScanCompareType compareType, long value1, long value2) { var sut = new LongMemoryComparer(compareType, value1, value2); Check.That(sut.CompareType).IsEqualTo(compareType); Check.That(sut.ValueSize).IsEqualTo(sizeof(long)); Check.That(sut.Value1).IsOneOf(value1, value2); Check.That(sut.Value2).IsOneOf(value1, value2); if (compareType == ScanCompareType.Between || compareType == ScanCompareType.BetweenOrEqual) { Check.That(sut.Value1 <= sut.Value2).IsTrue(); } }
private void searchForEqualValuesToolStripMenuItem_Click(object sender, EventArgs e) { var selectedNode = memoryViewControl.GetSelectedNodes().FirstOrDefault(); if (selectedNode == null) { return; } IScanComparer comparer; switch (selectedNode.Node) { case BaseHexNode node: comparer = new ArrayOfBytesMemoryComparer(node.ReadValueFromMemory(selectedNode.Memory)); break; case FloatNode node: comparer = new FloatMemoryComparer(ScanCompareType.Equal, ScanRoundMode.Normal, 2, node.ReadValueFromMemory(selectedNode.Memory), 0); break; case DoubleNode node: comparer = new DoubleMemoryComparer(ScanCompareType.Equal, ScanRoundMode.Normal, 2, node.ReadValueFromMemory(selectedNode.Memory), 0); break; case Int8Node node: comparer = new ByteMemoryComparer(ScanCompareType.Equal, (byte)node.ReadValueFromMemory(selectedNode.Memory), 0); break; case UInt8Node node: comparer = new ByteMemoryComparer(ScanCompareType.Equal, node.ReadValueFromMemory(selectedNode.Memory), 0); break; case Int16Node node: comparer = new ShortMemoryComparer(ScanCompareType.Equal, node.ReadValueFromMemory(selectedNode.Memory), 0); break; case UInt16Node node: comparer = new ShortMemoryComparer(ScanCompareType.Equal, (short)node.ReadValueFromMemory(selectedNode.Memory), 0); break; case Int32Node node: comparer = new IntegerMemoryComparer(ScanCompareType.Equal, node.ReadValueFromMemory(selectedNode.Memory), 0); break; case UInt32Node node: comparer = new IntegerMemoryComparer(ScanCompareType.Equal, (int)node.ReadValueFromMemory(selectedNode.Memory), 0); break; case Int64Node node: comparer = new LongMemoryComparer(ScanCompareType.Equal, node.ReadValueFromMemory(selectedNode.Memory), 0); break; case UInt64Node node: comparer = new LongMemoryComparer(ScanCompareType.Equal, (long)node.ReadValueFromMemory(selectedNode.Memory), 0); break; case Utf8TextNode node: comparer = new StringMemoryComparer(node.ReadValueFromMemory(selectedNode.Memory), Encoding.UTF8, true); break; case Utf16TextNode node: comparer = new StringMemoryComparer(node.ReadValueFromMemory(selectedNode.Memory), Encoding.Unicode, true); break; case Utf32TextNode node: comparer = new StringMemoryComparer(node.ReadValueFromMemory(selectedNode.Memory), Encoding.UTF32, true); break; default: return; } LinkedWindowFeatures.StartMemoryScan(comparer); }
public void TestCompareInvalidCompareTypeThrows(ScanCompareType compareType) { var sut = new LongMemoryComparer(compareType, 0L, 0L); Check.ThatCode(() => sut.Compare(BitConverter.GetBytes(0L), 0, out _)).Throws <InvalidCompareTypeException>(); }
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>(); }
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); }