public async Task ShouldUpdateAndDispatchPollPendingWhenScheduledReminderFirstReceived()
        {
            const string hostName    = "testhostname";
            const string snsTopicArn = "snsTopicArn";

            A.CallTo(() => _dao.Get(hostName)).Returns(new TlsEntityState(hostName)
            {
                TlsState = TlsState.Created, LastUpdated = null
            });
            A.CallTo(() => _tlsEntityConfig.SnsTopicArn).Returns(snsTopicArn);

            await _tlsEntity.Handle(new TlsScheduledReminder(Guid.NewGuid().ToString(), hostName));

            A.CallTo(() => _dao.Save(A <TlsEntityState> .That.Matches(e => e.TlsState == TlsState.PollPending))).MustHaveHappenedOnceExactly();
            A.CallTo(() => _dispatcher.Dispatch(A <TlsTestPending> .That.Matches(entity => entity.Id == hostName), snsTopicArn)).MustHaveHappenedOnceExactly();
        }
示例#2
0
        private async Task <TlsEntityState> LoadState(string id, string messageType)
        {
            TlsEntityState state = await _dao.Get(id);

            if (state == null)
            {
                state = new TlsEntityState(id);

                _log.LogError("Processing {EventName} - Tls Entity State does not exist for {Id}, creating new state.", messageType, id);
                await _dao.Save(state);

                _log.LogError("Tls Entity State created for {Id}.", id);

                TlsEntityCreated mxEntityCreated = new TlsEntityCreated(id);
                _dispatcher.Dispatch(mxEntityCreated, _tlsEntityConfig.SnsTopicArn);

                _log.LogInformation("Created _tlsEntityConfig for {Id}.", id);
            }

            return(state);
        }