public void testInjectRefereneValue_rdnAttributeDoesNotExist_notRequired_assertValueCollection()
 {
     var cert = new X509Certificate2(@"resources/certs/altNameOnly.der");
     var field = new SubjectAttributeField(false, RDNAttributeIdentifier.INITIALS);
     field.InjectReferenceValue(cert);
     field.GetPolicyValue().GetPolicyValue().Count.Should().Be(0);
 }
        public void testInjectRefereneValue_subjectAltNameDoesNotExist_required_assertException()
        {
            var cert = new X509Certificate2(@"resources/certs/altNameOnly.der");
            var field = new SubjectAttributeField(true, RDNAttributeIdentifier.INITIALS);

            Action action = () => field.InjectReferenceValue(cert);
            action.ShouldThrow<PolicyRequiredException>();
        }
        public void testInjectRefereneValue_distinguishedName_assertValue()
        {
            var cert = new X509Certificate2(@"resources/certs/altNameOnly.der");
            var field = new SubjectAttributeField(true, RDNAttributeIdentifier.DISTINGUISHED_NAME);

            field.InjectReferenceValue(cert);
            field.GetPolicyValue().GetPolicyValue().Count.Should().Be(1);
            field.GetPolicyValue()
                .GetPolicyValue()
                .FirstOrDefault()
                .Should()
                .Be("O=Cerner,L=Kansas City,S=MO,C=US,CN=altNameOnly");
        }
        public void testInjectRefereneValue_rdnSingleAttributeExists_assertValue()
        {
            var cert = new X509Certificate2(@"resources/certs/altNameOnly.der");
            var field = new SubjectAttributeField(true, RDNAttributeIdentifier.COMMON_NAME);

            field.InjectReferenceValue(cert);
            field.GetPolicyValue().GetPolicyValue().Count.Should().Be(1);
            field.GetPolicyValue()
                .GetPolicyValue()
                .FirstOrDefault()
                .Should()
                .Be("altNameOnly");
        }
 public void testInjectRefereneValue_noInjection_getPolicyValue_assertException()
 {
     var field = new SubjectAttributeField(true, RDNAttributeIdentifier.COMMON_NAME);
     Action action = () => field.GetPolicyValue();
     action.ShouldThrow<InvalidOperationException>();
 }