public async Task TestNotificationNotSentWhenAlreadyNotifiedFor1Day() { Mock <IHttpSysConfigurationProvider> httpSysProvider = new Mock <IHttpSysConfigurationProvider>(); var cert = this.CreateSelfSignedCert(DateTime.Now.Subtract(TimeSpan.FromDays(90)), DateTime.Now.Add(TimeSpan.FromHours(24))); httpSysProvider.Setup(t => t.GetCertificate()).Returns(cert); registryProvider.SetupGet(t => t.LastNotifiedCertificateKey).Returns($"{cert.Thumbprint}-1".ToLowerInvariant()); var job = new CertificateExpiryCheckJob(httpSysProvider.Object, this.logger, registryProvider.Object, smtpProvider.Object, adminNotificationOptions.Object); await job.Execute(Mock.Of <IJobExecutionContext>()); httpSysProvider.Verify(t => t.GetCertificate()); smtpProvider.VerifyGet(t => t.IsConfigured); smtpProvider.Verify(t => t.SendEmail(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never); registryProvider.VerifySet(t => t.LastNotifiedCertificateKey = It.IsAny <string>(), Times.Never); }