Beispiel #1
0
        public void ToScanResult_ScanError_ReturnsExpectedResult(string value)
        {
            // Arrange
            var rawResult = new RawScanResult(value);

            // Act
            var result = rawResult.ToScanResult();

            // Assert
            Assert.Equal(ScanStatus.Error, result.Status);
            Assert.Empty(result.InfectedFiles);
        }
Beispiel #2
0
        /// <summary>
        /// Scans the byte array for potential malicious content.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <ScanResult> ScanBytes(byte[] data)
        {
            using (var sourceStream = new MemoryStream(data))
            {
                var result = await this.CommandExecutor.Execute(ScanClientCommand.InStream,
                                                                (stream) => this.SendStreamFileChunks(sourceStream, stream));

                var rawResult = new RawScanResult(result);

                return(rawResult.ToScanResult());
            }
        }
Beispiel #3
0
        public void ToScanResult_VirusFound_ReturnsExpectedResult(string value)
        {
            // Arrange
            var rawResult = new RawScanResult(value);

            // Act
            var result = rawResult.ToScanResult();

            // Assert
            Assert.Equal(ScanStatus.VirusDetected, result.Status);
            Assert.Single(result.InfectedFiles);

            var infected = result.InfectedFiles.First();

            Assert.Equal(value, result.RawResult);
            Assert.Equal("stream", infected.FileName);
            Assert.Equal("Some-Virus-Name", infected.VirusName);
        }