import unittest
import sys
import pdb
sys.path.append("..")



class TestDetectCryptoMining(unittest.TestCase):

    def combineDetectionDicts(self, cpuMatches, memoryMatches, connectionMatches):
        combinedMatches = {}
        if bool(cpuMatches):
            for key in cpuMatches:
                combinedMatches[key] = cpuMatches[key]
                if bool(memoryMatches):
                    for key2 in memoryMatches:
                        if key == key2:
                            for item in memoryMatches[key2]:
                                combinedMatches[key].append(item)
                        elif key != key2 and key2 not in cpuMatches:
                            combinedMatches[key2] = memoryMatches[key2]
                else:
                    combinedMatches = cpuMatches

        else:
            combinedMatches = memoryMatches

        if bool(connectionMatches):
            for key in connectionMatches:
                if key in combinedMatches:
                    for item in connectionMatches[key]:
                        combinedMatches[key].append(item)
                elif key not in combinedMatches:
                    combinedMatches[key] = connectionMatches[key]

        return combinedMatches

    def test_combineDetections1(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        self.assertEqual(combinedMatches, {})

    def test_combineDetections2(self):
        cpuMatches = {}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        connectionMatches = {}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        self.assertEqual(combinedMatches, memoryMatches)

    def test_combineDetections3(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        self.assertEqual(combinedMatches, cpuMatches)


    def test_combineDetections4(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'MemoryUsageCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections5(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck', 'MemoryUsageCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections6(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)


    def test_combineDetections7(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections8(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)


    def test_combineDetections9(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)


    def test_combineDetections10(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections11(self):
        print("\n\ntest11")
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck'],
        'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck',
        'MemoryUsageCheck', 'SustainedHighMemoryCheck'],
        'firefox.exe': ['CPUPercentageCheck']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections12(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck'],
        'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck'], 'firefox.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
        'MemoryUsageCheck', 'SustainedHighMemoryCheck'],
        'firefox.exe': ['CPUPercentageCheck', 'SustainedHighMemoryCheck']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections13(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['MiningPoolConnection']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections14(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck', 'MiningPoolConnection']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections15(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck', 'MemoryUsageCheck', 'MiningPoolConnection']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections16(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck'],
        'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck'],
        'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection'],
        'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck', 'MiningPoolConnection'],
        'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck'], 'firefox.exe': ['MemoryUsageCheck', 'MiningPoolConnection']}

        pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("16 combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combinedDetections17(self):
        cpuMatches = {}
        memoryMatches = {'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'firefox.exe': ['MemoryUsageCheck', 'MiningPoolConnection']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        self.assertEqual(combinedMatches, expectedOutput)



if __name__ == '__main__':
    unittest.main()

331cca30eb94a1bd93a1533ac6983d0cb00cd372
<mask token>


class TestDetectCryptoMining(unittest.TestCase):

    def combineDetectionDicts(self, cpuMatches, memoryMatches,
        connectionMatches):
        combinedMatches = {}
        if bool(cpuMatches):
            for key in cpuMatches:
                combinedMatches[key] = cpuMatches[key]
                if bool(memoryMatches):
                    for key2 in memoryMatches:
                        if key == key2:
                            for item in memoryMatches[key2]:
                                combinedMatches[key].append(item)
                        elif key != key2 and key2 not in cpuMatches:
                            combinedMatches[key2] = memoryMatches[key2]
                else:
                    combinedMatches = cpuMatches
        else:
            combinedMatches = memoryMatches
        if bool(connectionMatches):
            for key in connectionMatches:
                if key in combinedMatches:
                    for item in connectionMatches[key]:
                        combinedMatches[key].append(item)
                elif key not in combinedMatches:
                    combinedMatches[key] = connectionMatches[key]
        return combinedMatches

    def test_combineDetections1(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, {})

    def test_combineDetections2(self):
        cpuMatches = {}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, memoryMatches)

    def test_combineDetections3(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        self.assertEqual(combinedMatches, cpuMatches)

    def test_combineDetections4(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections5(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections6(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)
    <mask token>

    def test_combineDetections8(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections9(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)
    <mask token>

    def test_combineDetections11(self):
        print('\n\ntest11')
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)
    <mask token>

    def test_combineDetections13(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)
    <mask token>
    <mask token>

    def test_combineDetections16(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck'], 'chrome.exe': [
            'CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection'],
            'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck',
            'MiningPoolConnection'], 'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('16 combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)
    <mask token>


<mask token>

<mask token>


class TestDetectCryptoMining(unittest.TestCase):

    def combineDetectionDicts(self, cpuMatches, memoryMatches,
        connectionMatches):
        combinedMatches = {}
        if bool(cpuMatches):
            for key in cpuMatches:
                combinedMatches[key] = cpuMatches[key]
                if bool(memoryMatches):
                    for key2 in memoryMatches:
                        if key == key2:
                            for item in memoryMatches[key2]:
                                combinedMatches[key].append(item)
                        elif key != key2 and key2 not in cpuMatches:
                            combinedMatches[key2] = memoryMatches[key2]
                else:
                    combinedMatches = cpuMatches
        else:
            combinedMatches = memoryMatches
        if bool(connectionMatches):
            for key in connectionMatches:
                if key in combinedMatches:
                    for item in connectionMatches[key]:
                        combinedMatches[key].append(item)
                elif key not in combinedMatches:
                    combinedMatches[key] = connectionMatches[key]
        return combinedMatches

    def test_combineDetections1(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, {})

    def test_combineDetections2(self):
        cpuMatches = {}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, memoryMatches)

    def test_combineDetections3(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        self.assertEqual(combinedMatches, cpuMatches)

    def test_combineDetections4(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections5(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections6(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections7(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections8(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections9(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections10(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections11(self):
        print('\n\ntest11')
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)
    <mask token>

    def test_combineDetections13(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections14(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections15(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections16(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck'], 'chrome.exe': [
            'CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection'],
            'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck',
            'MiningPoolConnection'], 'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('16 combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combinedDetections17(self):
        cpuMatches = {}
        memoryMatches = {'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, expectedOutput)


<mask token>

<mask token>


class TestDetectCryptoMining(unittest.TestCase):

    def combineDetectionDicts(self, cpuMatches, memoryMatches,
        connectionMatches):
        combinedMatches = {}
        if bool(cpuMatches):
            for key in cpuMatches:
                combinedMatches[key] = cpuMatches[key]
                if bool(memoryMatches):
                    for key2 in memoryMatches:
                        if key == key2:
                            for item in memoryMatches[key2]:
                                combinedMatches[key].append(item)
                        elif key != key2 and key2 not in cpuMatches:
                            combinedMatches[key2] = memoryMatches[key2]
                else:
                    combinedMatches = cpuMatches
        else:
            combinedMatches = memoryMatches
        if bool(connectionMatches):
            for key in connectionMatches:
                if key in combinedMatches:
                    for item in connectionMatches[key]:
                        combinedMatches[key].append(item)
                elif key not in combinedMatches:
                    combinedMatches[key] = connectionMatches[key]
        return combinedMatches

    def test_combineDetections1(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, {})

    def test_combineDetections2(self):
        cpuMatches = {}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, memoryMatches)

    def test_combineDetections3(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        self.assertEqual(combinedMatches, cpuMatches)

    def test_combineDetections4(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections5(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections6(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections7(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections8(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections9(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections10(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections11(self):
        print('\n\ntest11')
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections12(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck'],
            'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': [
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck'], 'firefox.exe':
            ['CPUPercentageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections13(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections14(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections15(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections16(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck'], 'chrome.exe': [
            'CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection'],
            'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck',
            'MiningPoolConnection'], 'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('16 combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combinedDetections17(self):
        cpuMatches = {}
        memoryMatches = {'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, expectedOutput)


<mask token>

<mask token>
sys.path.append('..')


class TestDetectCryptoMining(unittest.TestCase):

    def combineDetectionDicts(self, cpuMatches, memoryMatches,
        connectionMatches):
        combinedMatches = {}
        if bool(cpuMatches):
            for key in cpuMatches:
                combinedMatches[key] = cpuMatches[key]
                if bool(memoryMatches):
                    for key2 in memoryMatches:
                        if key == key2:
                            for item in memoryMatches[key2]:
                                combinedMatches[key].append(item)
                        elif key != key2 and key2 not in cpuMatches:
                            combinedMatches[key2] = memoryMatches[key2]
                else:
                    combinedMatches = cpuMatches
        else:
            combinedMatches = memoryMatches
        if bool(connectionMatches):
            for key in connectionMatches:
                if key in combinedMatches:
                    for item in connectionMatches[key]:
                        combinedMatches[key].append(item)
                elif key not in combinedMatches:
                    combinedMatches[key] = connectionMatches[key]
        return combinedMatches

    def test_combineDetections1(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, {})

    def test_combineDetections2(self):
        cpuMatches = {}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        connectionMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, memoryMatches)

    def test_combineDetections3(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        self.assertEqual(combinedMatches, cpuMatches)

    def test_combineDetections4(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections5(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections6(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections7(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections8(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections9(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections10(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        memoryMatches = {}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections11(self):
        print('\n\ntest11')
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck', 'MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['CPUPercentageCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections12(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck'],
            'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': [
            'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck'], 'firefox.exe':
            ['CPUPercentageCheck', 'SustainedHighMemoryCheck']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, None)
        print('combinedMatches', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections13(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections14(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections15(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections16(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck'], 'chrome.exe': [
            'CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck',
            'SustainedHighMemoryCheck'], 'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection'],
            'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck',
            'MemoryUsageCheck', 'SustainedHighMemoryCheck',
            'MiningPoolConnection'], 'chrome.exe': ['CPUPercentageCheck',
            'SustainedHighCPUCheck'], 'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        print('16 combinedMatches: ', combinedMatches)
        self.assertEqual(combinedMatches, expectedOutput)

    def test_combinedDetections17(self):
        cpuMatches = {}
        memoryMatches = {'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'firefox.exe': ['MemoryUsageCheck',
            'MiningPoolConnection']}
        combinedMatches = self.combineDetectionDicts(cpuMatches,
            memoryMatches, connectionMatches)
        self.assertEqual(combinedMatches, expectedOutput)


if __name__ == '__main__':
    unittest.main()

import unittest
import sys
import pdb
sys.path.append("..")



class TestDetectCryptoMining(unittest.TestCase):

    def combineDetectionDicts(self, cpuMatches, memoryMatches, connectionMatches):
        combinedMatches = {}
        if bool(cpuMatches):
            for key in cpuMatches:
                combinedMatches[key] = cpuMatches[key]
                if bool(memoryMatches):
                    for key2 in memoryMatches:
                        if key == key2:
                            for item in memoryMatches[key2]:
                                combinedMatches[key].append(item)
                        elif key != key2 and key2 not in cpuMatches:
                            combinedMatches[key2] = memoryMatches[key2]
                else:
                    combinedMatches = cpuMatches

        else:
            combinedMatches = memoryMatches

        if bool(connectionMatches):
            for key in connectionMatches:
                if key in combinedMatches:
                    for item in connectionMatches[key]:
                        combinedMatches[key].append(item)
                elif key not in combinedMatches:
                    combinedMatches[key] = connectionMatches[key]

        return combinedMatches

    def test_combineDetections1(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        self.assertEqual(combinedMatches, {})

    def test_combineDetections2(self):
        cpuMatches = {}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        connectionMatches = {}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        self.assertEqual(combinedMatches, memoryMatches)

    def test_combineDetections3(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        self.assertEqual(combinedMatches, cpuMatches)


    def test_combineDetections4(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'MemoryUsageCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections5(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck', 'MemoryUsageCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections6(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)


    def test_combineDetections7(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections8(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)


    def test_combineDetections9(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck']}
        memoryMatches = {'chrome.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck', 'SustainedHighMemoryCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)


    def test_combineDetections10(self):
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections11(self):
        print("\n\ntest11")
        cpuMatches = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck'],
        'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck',
        'MemoryUsageCheck', 'SustainedHighMemoryCheck'],
        'firefox.exe': ['CPUPercentageCheck']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections12(self):
        cpuMatches = {'chrome.exe': ['SustainedHighCPUCheck'],
        'firefox.exe': ['CPUPercentageCheck']}
        memoryMatches = {'chrome.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck'], 'firefox.exe': ['SustainedHighMemoryCheck']}
        expectedOutput = {'chrome.exe': ['SustainedHighCPUCheck',
        'MemoryUsageCheck', 'SustainedHighMemoryCheck'],
        'firefox.exe': ['CPUPercentageCheck', 'SustainedHighMemoryCheck']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, None)

        print("combinedMatches", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections13(self):
        cpuMatches = {}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['MiningPoolConnection']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections14(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck', 'MiningPoolConnection']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections15(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck', 'MemoryUsageCheck', 'MiningPoolConnection']}

        #pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combineDetections16(self):
        cpuMatches = {'xmrig.exe': ['CPUPercentageCheck'],
        'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck']}
        memoryMatches = {'xmrig.exe': ['MemoryUsageCheck', 'SustainedHighMemoryCheck'],
        'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'xmrig.exe': ['MiningPoolConnection'],
        'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'xmrig.exe': ['CPUPercentageCheck', 'MemoryUsageCheck', 'SustainedHighMemoryCheck', 'MiningPoolConnection'],
        'chrome.exe': ['CPUPercentageCheck', 'SustainedHighCPUCheck'], 'firefox.exe': ['MemoryUsageCheck', 'MiningPoolConnection']}

        pdb.set_trace()
        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        print("16 combinedMatches: ", combinedMatches)

        self.assertEqual(combinedMatches, expectedOutput)

    def test_combinedDetections17(self):
        cpuMatches = {}
        memoryMatches = {'firefox.exe': ['MemoryUsageCheck']}
        connectionMatches = {'firefox.exe': ['MiningPoolConnection']}
        expectedOutput = {'firefox.exe': ['MemoryUsageCheck', 'MiningPoolConnection']}

        combinedMatches = self.combineDetectionDicts(cpuMatches, memoryMatches, connectionMatches)

        self.assertEqual(combinedMatches, expectedOutput)



if __name__ == '__main__':
    unittest.main()
