using System; using System.Collections.Generic; using System.Threading.Tasks; using MalwareMultiScan.Api.Data; using MalwareMultiScan.Api.Data.Configuration; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Memory; using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; namespace MalwareMultiScan.Tests.Api { public class ScanBackendServiceTests { private Mock _busMock; private IScanBackendService _scanBackendService; [SetUp] public void SetUp() { var configuration = new ConfigurationRoot(new List { new MemoryConfigurationProvider(new MemoryConfigurationSource()) }) { ["BackendsConfiguration"] = "backends.yaml" }; _busMock = new Mock(); _scanBackendService = new ScanBackendService( configuration, _busMock.Object, Mock.Of>()); } [Test] public void TestBackendsAreNotEmpty() { Assert.IsNotEmpty(_scanBackendService.List); } [Test] public async Task TestQueueUrlScan() { await _scanBackendService.QueueUrlScan( new ScanResult {Id = "test"}, new ScanBackend {Id = "dummy"}, "http://test.com" ); _busMock.Verify(x => x.SendAsync( "dummy", It.Is(r => r.Id == "test" && r.Uri == new Uri("http://test.com"))), Times.Once); } } }