public void when_a_constructor_argument_is_invalid_then_an_exception_is_thrown() { An <ArgumentNullException> .ShouldBeThrownBy(() => new InMemoryCertificate(null, 2.seconds(), new ControllableTimeProvider())); An <ArgumentException> .ShouldBeThrownBy(() => new InMemoryCertificate(new X509Certificate2(), 0.seconds(), new ControllableTimeProvider())); An <ArgumentException> .ShouldBeThrownBy(() => new InMemoryCertificate(new X509Certificate2(), new TimeSpan(-1L), new ControllableTimeProvider())); An <ArgumentNullException> .ShouldBeThrownBy(() => new InMemoryCertificate(new X509Certificate2(), 2.seconds(), null)); }
public void when_a_constructor_argument_is_invalid_then_an_exception_is_thrown() { var timeProvider = new Mock <ITimeProvider>().Object; var certificateProvider = new Mock <ICertificateProvider>().Object; An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(null, certificateProvider, certificateProvider, certificateProvider, timeProvider, 1.seconds())); An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(certificateProvider, null, certificateProvider, certificateProvider, timeProvider, 1.seconds())); An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(certificateProvider, certificateProvider, null, certificateProvider, timeProvider, 1.seconds())); An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(certificateProvider, certificateProvider, certificateProvider, null, timeProvider, 1.seconds())); An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(certificateProvider, certificateProvider, certificateProvider, certificateProvider, null, 1.seconds())); An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(certificateProvider, certificateProvider, certificateProvider, certificateProvider, null, 0.seconds())); An <ArgumentNullException> .ShouldBeThrownBy(() => new AzureKeyVaultCertificateStore(certificateProvider, certificateProvider, certificateProvider, certificateProvider, null, new TimeSpan(-1L))); }
public void when_expiration_date_has_passed_then_getting_the_value_throws_an_exception() { timeProvider.Now = timeProvider.Now + certificateInMemLifeSpan + 1.seconds(); An <Exception> .ShouldBeThrownBy(() => certificate.X509); }