public void SignXml() { var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; var dataPath = Path.Combine(path, "Data", "test.xml"); try { SetupCertificate(); new XElement(nameof(SignXml)).Save(dataPath); var xmlDoc = new XmlDocument(); xmlDoc.PreserveWhitespace = true; xmlDoc.Load(dataPath); var cert = XmlExtensions.GetCertificate("CN=Gnu.Licensing", StoreName.My, StoreLocation.CurrentUser); XmlExtensions.SignXml(xmlDoc, cert); bool result = XmlExtensions.VerifyXmlFile(xmlDoc); Assert.True(result); } finally { File.Delete(dataPath); } }