Beispiel #1
0
        public void ScanFile_ThrowsFileNotFound_ForCandidate()
        {
            var result = VirusScanService.ScanFile("save");

            result.Success.Should().BeFalse();
            result.IsThread.Should().BeNull();
            result.Exception.Should().BeOfType(typeof(FileNotFoundException));
        }
Beispiel #2
0
        public void ScanFile_ThrowsFileNotFound_ForScanner()
        {
            var save = Encoding.ASCII.GetBytes(@"123");

            File.WriteAllBytes("save", save);

            var result = VirusScanService.ScanFile("save", "123.exe");

            result.Success.Should().BeFalse();
            result.IsThread.Should().BeNull();
            result.Exception.Should().BeOfType(typeof(FileNotFoundException));
        }
Beispiel #3
0
        public void ScanFile_DeclaresSave()
        {
            var save = Encoding.ASCII.GetBytes(@"123");

            File.WriteAllBytes("save", save);


            var result = VirusScanService.ScanFile("save");

            result.Success.Should().BeTrue();
            result.IsThread.Should().BeFalse();
        }
Beispiel #4
0
        public void ScanFile_Detects()
        {
            var eicar = Encoding.ASCII.GetBytes(@"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");

            File.WriteAllBytes("eicar", eicar);


            var result = VirusScanService.ScanFile("eicar");

            result.Success.Should().BeTrue();
            result.IsThread.Should().BeTrue();
        }
Beispiel #5
0
        public ScannerController(URLContext context, ScannerService scannerService, VirusScanService virusScanService)
        {
            // Initializing an in-memory database for saving requests and responses for measuring purposes
            _context          = context;
            _scannerService   = scannerService;
            _virusScanService = virusScanService;

            if (_context.URLItems.Count() == 0)
            {
                _context.URLItems.Add(new URLItem {
                    Url = "http://foobar.com"
                });
                _context.SaveChanges();
            }
        }