public async Task PollNxDomainReturnsExpectedResult()
        {
            await PurgeAmazonSqsQueue(OutputQueueUrl);

            SpfPollPending spfRecordExpired = new SpfPollPending(DomainWithNxDomainResult);

            InvokeLambda(spfRecordExpired);

            List <Message> messages = await ReadAmazonSqsEvent(OutputQueueUrl, ReadTimeoutSecond);

            Assert.That(messages.Count, Is.EqualTo(1));
            Assert.That(messages[0], Is.TypeOf <SpfRecordsPolled>());

            SpfRecordsPolled spfRecordsPolled = (SpfRecordsPolled)messages[0];

            Assert.That(spfRecordsPolled.Id, Is.EqualTo(spfRecordsPolled.Id));
            Assert.That(spfRecordsPolled.Records.Records, Is.Empty);
            Assert.That(spfRecordsPolled.DnsQueryCount, Is.Null);
            Assert.That(spfRecordsPolled.ElapsedQueryTime, Is.Null);
            Assert.That(spfRecordsPolled.Messages.Count, Is.EqualTo(1));
            StringAssert.StartsWith("Failed SPF record query for", spfRecordsPolled.Messages[0].Text);
        }
        public async Task PollDomainWithoutSpfReturnsExpectedResult()
        {
            await PurgeAmazonSqsQueue(OutputQueueUrl);

            SpfPollPending spfRecordExpired = new SpfPollPending(DomainWithoutSpf);

            InvokeLambda(spfRecordExpired);

            List <Message> messages = await ReadAmazonSqsEvent(OutputQueueUrl, ReadTimeoutSecond);

            Assert.That(messages.Count, Is.EqualTo(1));
            Assert.That(messages[0], Is.TypeOf <SpfRecordsPolled>());

            SpfRecordsPolled spfRecordsPolled = (SpfRecordsPolled)messages[0];

            Assert.That(spfRecordsPolled.Id, Is.EqualTo(spfRecordsPolled.Id));
            Assert.That(spfRecordsPolled.Records.Records, Is.Empty);
            Assert.That(spfRecordsPolled.DnsQueryCount, Is.EqualTo(0));
            Assert.That(spfRecordsPolled.ElapsedQueryTime, Is.Not.Null);
            Assert.That(spfRecordsPolled.Records.Messages.Count, Is.EqualTo(1));
            StringAssert.StartsWith("500.uk.com: Domain should have exactly 1 SPF record. This domain has 0.", spfRecordsPolled.Records.Messages[0].Text);
        }
        public async Task PollDomainWithSpfReturnsExpectedResult()
        {
            await PurgeAmazonSqsQueue(OutputQueueUrl);

            SpfPollPending spfRecordExpired = new SpfPollPending(DomainWithSpf);

            InvokeLambda(spfRecordExpired);

            List <Message> messages = await ReadAmazonSqsEvent(OutputQueueUrl, ReadTimeoutSecond);

            Assert.That(messages.Count, Is.EqualTo(1));
            Assert.That(messages[0], Is.TypeOf <SpfRecordsPolled>());

            SpfRecordsPolled spfRecordsPolled = (SpfRecordsPolled)messages[0];

            Assert.That(spfRecordsPolled.Id, Is.EqualTo(spfRecordsPolled.Id));

            Assert.That(spfRecordsPolled.DnsQueryCount, Is.EqualTo(2));
            Assert.That(spfRecordsPolled.ElapsedQueryTime, Is.Not.Null);
            Assert.That(spfRecordsPolled.Records.Records.Count, Is.EqualTo(1));
            Assert.That(spfRecordsPolled.Records.PayloadSizeBytes, Is.EqualTo(ExpectedRecordSize));
            Assert.That(spfRecordsPolled.Records.Records[0].Record, Is.EqualTo(ExpectedSpfRecord));
            Assert.That(spfRecordsPolled.Records.Messages, Is.Empty);
        }