public void TestMethodShouldReturnTrue()
        {
            // If this test fails, it's because virus scanning on the machine is not working.
            var subject = new MalwareScanner(AppName);
            var result  = subject.TestIfItIsWorking();

            Assert.True(result.IsItWorking);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var virus = Encoding.UTF8.GetBytes(
                "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");

            using (var scanner = new MalwareScanner())
            {
                var selfTest = scanner.TestIfItIsWorking();
                Console.WriteLine($"IsItWorking: {selfTest.IsItWorking}");
                Console.WriteLine($"Exception: {selfTest.Exception}");
                var result = scanner.HasVirus(virus, nameof(virus));
                Console.WriteLine($"HasVirus: {result}");
                //// ToDo: log positive scan result or selfTest.IsItWorking != true
            }
        }
Exemplo n.º 3
0
        private Task <ScanResultModel> SendAsync(Func <bool> calback)
        {
            var result = _amsiService.TestIfItIsWorking();

            if (!result.IsItWorking)
            {
                throw new ScanFileException(result.ErrorMessage);
            }

            var hasVirus = calback();

            return(Task.FromResult(new ScanResultModel
            {
                HasVirus = hasVirus,
                Message = !hasVirus ? "No Virus found" : "Virus found",
            }));
        }