public void GetXml() { DsaKeyValue dsa = new DsaKeyValue(); XmlElement xmlkey = dsa.GetXml(); XmlNamespaceManager ns = new XmlNamespaceManager(xmlkey.OwnerDocument.NameTable); ns.AddNamespace("schema", XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]); IEnumerable <XmlNode> elements = new[] { "P", "Q", "G", "Y", "J", "Seed", "PgenCounter" } .Select(elementName => xmlkey.SelectSingleNode($"/schema:DSAKeyValue/schema:{elementName}", ns)) .Where(element => element != null); Assert.NotEmpty(elements); Assert.True(elements.SingleOrDefault(element => element.Name == "Y") != null); Assert.True(elements.All(element => !string.IsNullOrEmpty(element.InnerText))); elements.Select(element => Convert.FromBase64String(element.InnerText)); }
public void GetXml_SameDsa() { var pair = TestHelpers.DSAGenerateKeyPair(); DsaKeyValue dsaKeyValue1 = new DsaKeyValue((DsaPublicKeyParameters)pair.Public); DsaKeyValue dsaKeyValue2 = new DsaKeyValue((DsaPublicKeyParameters)pair.Public); Assert.Equal(dsaKeyValue1.GetXml(), dsaKeyValue2.GetXml()); }