public async Task ItShouldSaveAndDispatchTheTlsRptStateIfItDoesntExist() { A.CallTo(() => _dao.Get(A <string> ._)).Returns <TlsRptSchedulerState>(null); await _sut.Handle(new TlsRptEntityCreated("ncsc.gov.uk", 1)); A.CallTo(() => _dao.Save(A <TlsRptSchedulerState> ._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _dispatcher.Dispatch(A <TlsRptRecordExpired> ._, A <string> ._)) .MustHaveHappenedOnceExactly(); }
public async Task Handle(TlsRptEntityCreated message) { string domain = message.Id.ToLower(); TlsRptSchedulerState state = await _dao.Get(domain); if (state == null) { state = new TlsRptSchedulerState(domain); await _dao.Save(state); _dispatcher.Dispatch(state.ToTlsRptRecordExpiredMessage(), _config.PublisherConnectionString); _log.LogInformation($"New {nameof(TlsRptSchedulerState)} saved for {domain}"); } else { _log.LogInformation($"{nameof(TlsRptSchedulerState)} already exists for {domain}"); } }