unit tests for API (99% coverage)

This commit is contained in:
Volodymyr Smirnov
2020-10-29 12:17:09 +02:00
parent 7f2528eb1d
commit b2902c128a
20 changed files with 565 additions and 130 deletions

View File

@@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using MalwareMultiScan.Api.Attributes;
using MalwareMultiScan.Api.Data.Models;
using MalwareMultiScan.Api.Services;
using MalwareMultiScan.Api.Services.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -13,9 +13,9 @@ namespace MalwareMultiScan.Api.Controllers
[Produces("application/json")]
public class QueueController : Controller
{
private readonly ScanResultService _scanResultService;
private readonly IScanResultService _scanResultService;
public QueueController(ScanResultService scanResultService)
public QueueController(IScanResultService scanResultService)
{
_scanResultService = scanResultService;
}
@@ -31,10 +31,10 @@ namespace MalwareMultiScan.Api.Controllers
string storedFileId;
await using (var uploadFileStream = file.OpenReadStream())
storedFileId = await _scanResultService.StoreFile(file.Name, uploadFileStream);
storedFileId = await _scanResultService.StoreFile(file.FileName, uploadFileStream);
await _scanResultService.QueueUrlScan(result, Url.Action("Index", "Download", new {id = storedFileId},
Request.Scheme, Request.Host.Value));
Request?.Scheme, Request?.Host.Value));
return CreatedAtAction("Index", "ScanResults", new {id = result.Id}, result);
}