예제 #1
0
        public async Task PublishesDomainMissingMessageWhenDomainDoesNotExist()
        {
            A.CallTo(() => _dao.GetDkimSelectors("testDomain"))
            .Returns(Task.FromResult <EntityDkimEntityState>(null));

            EntityDkimEntityState result = await _dkimService.GetDkimForDomain("testDomain");

            A.CallTo(() => _messagePublisher.Publish(A <DomainMissing> ._, A <string> ._))
            .MustHaveHappenedOnceExactly();
            Assert.AreEqual(null, result);
        }
        public async Task <EntityDkimEntityState> GetDkimForDomain(string requestDomain)
        {
            EntityDkimEntityState response = await _dao.GetDkimSelectors(requestDomain);

            if (response?.RecordsLastUpdated == null || response.RecordsLastUpdated.Value.AddDays(DaysBeforeBeingConsideredStale) <= _clock.GetDateTimeUtc())
            {
                await _messagePublisher.Publish(new DomainMissing(requestDomain), _config.MicroserviceOutputSnsTopicArn);
            }

            return(response);
        }