public void Test_DkimWorker_NoSelectors()
        {
            // Arrange
            var workerInformation = MockWorkerInformation(hostname: "google.com");

            var settingsMock = Utils.CreateMock <ISettings>();

            settingsMock.Setup(x => x.DkimSelectors).Returns(new List <string>());

            var lookupClientMock = Utils.CreateMock <ILookupClient>();

            var previousWorkerMock = Utils.CreateMock <IAsyncWorker>();

            previousWorkerMock.Setup(x => x.Scan(workerInformation)).Returns(Task.FromResult(MockScanResults()));

            var worker = new DkimWorker(previousWorkerMock.Object, lookupClientMock.Object, settingsMock.Object);

            // Act
            var rawRecords = worker.Scan(workerInformation);

            rawRecords.Wait();

            // Assert
            var records = rawRecords.Result;

            Assert.AreEqual(3, records.Count);

            AssertPreviousScanResults(new[] { records[0], records[1] }.ToList());
            AssertDkimResponse(records[2], null, new List <(string, QueryType, List <string>)>(), false);
        }
        public void Test_DkimWorker_OneSelectors_Txt()
        {
            // Arrange
            var workerInformation    = MockWorkerInformation(hostname: "google.com");
            var hostnameWithSelector = "selector1._domainkey.google.com";

            var settingsMock = Utils.CreateMock <ISettings>();

            settingsMock.Setup(x => x.DkimSelectors).Returns(new List <string>()
            {
                "selector1._domainkey"
            });

            var lookupClientMock = Utils.CreateMock <ILookupClient>();

            var resourceRecord = new ResourceRecordInfo(DnsString.FromResponseQueryString(hostnameWithSelector), ResourceRecordType.TXT, QueryClass.IN, 0, 0);
            var txtRecords     = new[] { "v=DKIM <key>" };

            var dnsRecords = new List <TxtRecord>()
            {
                new TxtRecord(resourceRecord, txtRecords, txtRecords)
            };

            var dnsResponse = new Mock <IDnsQueryResponse>();

            dnsResponse.Setup(x => x.Answers).Returns(dnsRecords);

            lookupClientMock.Setup(x => x.QueryAsync(hostnameWithSelector, QueryType.TXT, QueryClass.IN, null, default)).Returns(Task.FromResult(dnsResponse.Object));

            var previousWorkerMock = MockPreviousWorker(workerInformation);
            var worker             = new DkimWorker(previousWorkerMock.Object, lookupClientMock.Object, settingsMock.Object);

            // Act
            var rawRecords = worker.Scan(workerInformation);

            rawRecords.Wait();

            // Assert
            var records = rawRecords.Result;

            Assert.AreEqual(3, records.Count);

            AssertPreviousScanResults(new[] { records[0], records[1] }.ToList());
            AssertDkimResponse(records[2], null, new[] { ("selector1._domainkey", QueryType.TXT, txtRecords.ToList()) }.ToList(), true);