public void Test_MxWorker_Scan_NoMxRecords() { //Arrange var workerInformation = MockWorkerInformation(hostname: "google.com"); var dnsResponse = new Mock <IDnsQueryResponse>(); dnsResponse.Setup(x => x.Answers).Returns(new List <DnsResourceRecord>()); var lookupClientMock = Utils.CreateMock <ILookupClient>(); lookupClientMock.Setup(x => x.QueryAsync(workerInformation.Hostname, QueryType.MX, QueryClass.IN, null, default)).Returns(Task.FromResult(dnsResponse.Object)); var previousWorkerMock = Utils.CreateMock <IAsyncWorker>(); previousWorkerMock.Setup(x => x.Scan(workerInformation)).Returns(Task.FromResult(MockScanResults())); var service = new MxWorker(previousWorkerMock.Object, lookupClientMock.Object); //Act var rawMxRecords = service.Scan(workerInformation); rawMxRecords.Wait(); // Assert var records = rawMxRecords.Result; Assert.AreEqual(3, records.Count); AssertPreviousScanResults(new[] { records[0], records[1] }.ToList()); AssertMxResponse(records[2], new List <string>(), false); }
public async Task <List <ScanResult> > ScanDns(WorkerInformation workerInformation) { var baseWorker = new BaseWorker(); var mxWorker = new MxWorker(baseWorker, this.LookupClient); var dkimWorker = new DkimWorker(mxWorker, this.LookupClient, this.Settings); var caaWorker = new CaaWorker(dkimWorker, this.LookupClient); var spfWorker = new SpfWorker(caaWorker, this.LookupClient); var dnssecWorker = new DnssecWorker(spfWorker, this.LookupClient); var dmarcWorker = new DmarcWorker(dnssecWorker, this.LookupClient); var scanResults = await dmarcWorker.Scan(workerInformation); return(scanResults); }