public void Constructor_X509Certificate_X509IncludeOption()
        {
            KeyInfoX509Data data = new KeyInfoX509Data(new X509CertificateParser().ReadCertificate(cert) /*, X509IncludeOption.EndCertOnly*/);

            Assert.Equal(1, data.Certificates.Count);
            Assert.Null(data.GetCRL());
            Assert.Null(data.IssuerSerials);
            Assert.Null(data.SubjectKeyIds);
            Assert.Null(data.SubjectNames);
        }
        public void Constructor_Empty()
        {
            KeyInfoX509Data data = new KeyInfoX509Data();

            Assert.Null(data.Certificates);
            Assert.Null(data.GetCRL());
            Assert.Null(data.IssuerSerials);
            Assert.Null(data.SubjectKeyIds);
            Assert.Null(data.SubjectNames);
            Assert.Equal(data.GetXml().OuterXml, "<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />");
        }
        public void AddSubjectKeyId_String_BadHexData()
        {
            KeyInfoX509Data data = new KeyInfoX509Data();

            data.AddSubjectKeyId("Hello");
            Assert.Null(data.Certificates);
            Assert.Null(data.GetCRL());
            Assert.Null(data.IssuerSerials);
            Assert.Equal(1, data.SubjectKeyIds.Count);
            Assert.Null(data.SubjectNames);
        }
        public void Constructor_X509Certificate_X509IncludeOptionBad()
        {
            KeyInfoX509Data data = new KeyInfoX509Data(new X509CertificateParser().ReadCertificate(cert), Enumerable.Empty <X509Certificate>(), (X509IncludeOption)int.MinValue);

            Assert.Null(data.Certificates);
            Assert.Null(data.GetCRL());
            Assert.Null(data.IssuerSerials);
            Assert.Null(data.SubjectKeyIds);
            Assert.Null(data.SubjectNames);
            Assert.Equal("<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", data.GetXml().OuterXml);
        }
        public void AddSubjectName_Null()
        {
            KeyInfoX509Data data = new KeyInfoX509Data();

            data.AddSubjectName(null);
            Assert.Null(data.Certificates);
            Assert.Null(data.GetCRL());
            Assert.Null(data.IssuerSerials);
            Assert.Null(data.SubjectKeyIds);
            Assert.Equal(1, data.SubjectNames.Count);
            Assert.Null(data.SubjectNames[0]);
            Assert.Equal("<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509SubjectName></X509SubjectName></X509Data>", data.GetXml().OuterXml);
        }
        public void CRL()
        {
            KeyInfoX509Data data1 = new KeyInfoX509Data();

            data1.SetCRL(x509crl);
            XmlElement xel = data1.GetXml();

            KeyInfoX509Data data2 = new KeyInfoX509Data();

            data2.LoadXml(xel);

            Assert.Equal((data1.GetXml().OuterXml), (data2.GetXml().OuterXml));
            Assert.Equal(data1.GetCRL(), data2.GetCRL());
        }
        public void AddSubjectKeyId_Byte_Null()
        {
            KeyInfoX509Data data = new KeyInfoX509Data();

            data.AddSubjectKeyId((byte[])null);
            Assert.Null(data.Certificates);
            Assert.Null(data.GetCRL());
            Assert.Null(data.IssuerSerials);
            Assert.Equal(1, data.SubjectKeyIds.Count);
            Assert.Null(data.SubjectNames);



            Assert.Throws <ArgumentNullException>(() => data.GetXml().OuterXml);
        }