コード例 #1
0
        public void UseCertificateWithThumbprint_SetsTheCertificateInformationCorrectly()
        {
            Binding binding = WebAdministrationFactory.CreateBinding();

            var finder = Substitute.For<ICertificateFinder>();
            var certificate = CertificateFactory.CreateCertificate();

            var result = new CertificateFindResult(StoreLocation.LocalMachine, StoreName.My, certificate);

            finder.Find(X509FindType.FindByThumbprint, certificate.Thumbprint).Returns(result);

            var sut = new BindingConfigurer(binding) {CertificateFinder = finder};

            sut.UseCertificateWithThumbprint(certificate.Thumbprint);

            Assert.Equal("https", binding.Protocol);
            Assert.Equal(certificate.GetCertHash(), binding.CertificateHash);
            Assert.Equal("My", binding.CertificateStoreName);
        }
コード例 #2
0
        public void UseCertificateWithThumbprint_ThrowsWhenNoCertificateExistsWIthTheThumbprint()
        {
            Binding binding = WebAdministrationFactory.CreateBinding();

            var finder = Substitute.For<ICertificateFinder>();

            var result = new CertificateFindResult();

            var thumbprint = "notfoundthumprint";

            finder.Find(X509FindType.FindByThumbprint, thumbprint).Returns(result);

            var sut = new BindingConfigurer(binding) { CertificateFinder = finder };

            Assert.Throws<InstallationException>(() => sut.UseCertificateWithThumbprint(thumbprint));
        }