コード例 #1
0
 public void TestDeleteKey()
 {
     //Setup
     RegistryEdit reg = new RegistryEdit();
     KeyObject keyObject = new KeyObject("firstname", "lastname", "TestCompany", "TestProductName", "1.0.0");
     string regPath = KeyUtil.BuildRegPath(keyObject);
     Assert.IsNotNull(reg.WriteKey(regPath)); 
     //Execute  
     Assert.IsTrue(reg.DeleteKey(regPath, "TestCompany"));
     //Verify
     Assert.IsNull(reg.Read(regPath)); 
     //Undo
 }
コード例 #2
0
 public void TestRead()
 {
     //Setup
     RegistryEdit reg = new RegistryEdit();
     KeyObject keyObject = new KeyObject("firstname", "lastname", "TestCompany", "TestProductName", "1.0.0");
     string regPath = KeyUtil.BuildRegPath(keyObject);
     reg.DeleteKey(regPath, "TestCompany");
     //Execute  
     //Verify
     try 
     {
         reg.Read(null);
     }
     catch (Exception ex) { Assert.IsTrue(true, ex.Message); }
     Assert.IsNull(reg.Read(regPath)); //Non-existant reg key
     //Undo
 }
コード例 #3
0
        public void TestWriteValue()
        {
            //Setup
            RegistryEdit reg = new RegistryEdit();
            KeyObject keyObject = new KeyObject("firstname", "lastname", "TestCompany", "TestProductName", "1.0.0");
            string regPath = KeyUtil.BuildRegPath(keyObject);
            Assert.IsNotNull(reg.WriteKey(regPath)); 
            //Execute    
            try
            {
                reg.WriteValue(null, null, null);
            }
            catch (Exception ex) { Assert.IsTrue(true, ex.Message); }

            try
            {
                reg.WriteValue(regPath, "testkey", null);
            }
            catch (Exception ex) { Assert.IsTrue(true, ex.Message); }

            Assert.IsTrue(reg.WriteValue(regPath, "testkey", "testvalue")); 
            //Verify
            //Undo
            Assert.IsTrue(reg.DeleteKey(regPath, "TestCompany"));
        }
コード例 #4
0
ファイル: KeyUtil.cs プロジェクト: dalehenning/LicenseLib.NET
 public static bool UninstallKey(KeyObject key)
 {
     RegistryEdit reg = new RegistryEdit();
     string keyPath = BuildRegPath(key);
     return reg.DeleteKey(keyPath, key.CompanyName);
 }