Ejemplo n.º 1
0
 public void GetAllSubkeysTest_SubKeysNoValues()
 {
     using (RegistryTestContext context = new RegistryTestContext())
     {
         Registry.RetrieveAllRegistrySubkeyValues <string>(RegistryHive.CurrentUser, context.InstanceKey).Should().BeEmpty();
     }
 }
Ejemplo n.º 2
0
 public void GetAllSubkeysTest_SetValueNoKey()
 {
     using (RegistryTestContext context = new RegistryTestContext())
     {
         string subkey = context.InstanceKey + @"\Flozzle";
         Registry.SetRegistryValue<string>(RegistryHive.CurrentUser, subkey, "Nozzle", "Wozzle").Should().BeTrue();
         Registry.RetrieveRegistryValue<string>(RegistryHive.CurrentUser, subkey, "Nozzle").Should().Be("Wozzle");
     }
 }
Ejemplo n.º 3
0
 public void GetAllSubkeysTest_SetValueNoKey()
 {
     using (RegistryTestContext context = new RegistryTestContext())
     {
         string subkey = context.InstanceKey + @"\Flozzle";
         Registry.SetRegistryValue <string>(RegistryHive.CurrentUser, subkey, "Nozzle", "Wozzle").Should().BeTrue();
         Registry.RetrieveRegistryValue <string>(RegistryHive.CurrentUser, subkey, "Nozzle").Should().Be("Wozzle");
     }
 }
Ejemplo n.º 4
0
 public void GetAllSubkeysTest_SubKeysValues()
 {
     using (RegistryTestContext context = new RegistryTestContext())
     {
         Registry.SetRegistryValue <string>(RegistryHive.CurrentUser, context.InstanceKey + @"\Foo", "Foo1", "one");
         Registry.SetRegistryValue <string>(RegistryHive.CurrentUser, context.InstanceKey + @"\Foo", "Foo2", "two");
         Registry.SetRegistryValue <string>(RegistryHive.CurrentUser, context.InstanceKey + @"\Bar", null, "three");
         Registry.RetrieveAllRegistrySubkeyValues <string>(RegistryHive.CurrentUser, context.InstanceKey).Should().BeEquivalentTo("one", "two", "three");
     }
 }
Ejemplo n.º 5
0
        public void BasicTests()
        {
            using (RegistryTestContext context = new RegistryTestContext())
            {
                Registry.RetrieveRegistryValue <string>(RegistryHive.CurrentUser, context.InstanceKey, "").Should().Be("DefaultValue", "default value for key returned with empty string");
                Registry.SetRegistryValue <string>(RegistryHive.CurrentUser, context.InstanceKey, null, "NewValue").Should().Be(true, "setting default value should be successful");
                Registry.RetrieveRegistryValue <string>(RegistryHive.CurrentUser, context.InstanceKey, null).Should().Be("NewValue", "default value for key returned with null");
                Registry.RetrieveRegistryValue <byte[]>(RegistryHive.CurrentUser, context.InstanceKey, "MeaningBinary").Should().Equal(RegistryTestContext.ByteArray, "byte array should be identical");
                Registry.RetrieveRegistryValue <string[]>(RegistryHive.CurrentUser, context.InstanceKey, "MeaningStringArray").Should().Equal(RegistryTestContext.StringArray, "string array should be identical");

                bool?triState = true;
                Registry.SetRegistryValue(RegistryHive.CurrentUser, context.InstanceKey, "Foo", triState).Should().BeTrue("successfully set triState bool with default type");
                Registry.RetrieveRegistryValue <bool>(RegistryHive.CurrentUser, context.InstanceKey, "Foo").Should().BeTrue("successfully retrieved bool? as bool");
                Registry.RetrieveRegistryValue <bool?>(RegistryHive.CurrentUser, context.InstanceKey, "Foo").Should().BeTrue("successfully retrieved bool? as bool?");
                triState = null;
                Registry.SetRegistryValue(RegistryHive.CurrentUser, context.InstanceKey, "Foo", triState).Should().BeTrue("successfully set tristate bool as null");
                Registry.RetrieveRegistryValue <bool?>(RegistryHive.CurrentUser, context.InstanceKey, "Foo").Should().NotHaveValue("successfully retrieved bool? as null bool?");

                Registry.GetSubkeyNames(RegistryHive.CurrentUser, context.InstanceKey).Should().HaveCount(2);
            }
        }
Ejemplo n.º 6
0
        public void BasicTests()
        {
            using (RegistryTestContext context = new RegistryTestContext())
            {
                Registry.RetrieveRegistryValue<string>(RegistryHive.CurrentUser, context.InstanceKey, "").Should().Be("DefaultValue", "default value for key returned with empty string");
                Registry.SetRegistryValue<string>(RegistryHive.CurrentUser, context.InstanceKey, null, "NewValue").Should().Be(true, "setting default value should be successful");
                Registry.RetrieveRegistryValue<string>(RegistryHive.CurrentUser, context.InstanceKey, null).Should().Be("NewValue", "default value for key returned with null");
                Registry.RetrieveRegistryValue<byte[]>(RegistryHive.CurrentUser, context.InstanceKey, "MeaningBinary").Should().Equal(RegistryTestContext.ByteArray, "byte array should be identical");
                Registry.RetrieveRegistryValue<string[]>(RegistryHive.CurrentUser, context.InstanceKey, "MeaningStringArray").Should().Equal(RegistryTestContext.StringArray, "string array should be identical");

                bool? triState = true;
                Registry.SetRegistryValue(RegistryHive.CurrentUser, context.InstanceKey, "Foo", triState).Should().BeTrue("successfully set triState bool with default type");
                Registry.RetrieveRegistryValue<bool>(RegistryHive.CurrentUser, context.InstanceKey, "Foo").Should().BeTrue("successfully retrieved bool? as bool");
                Registry.RetrieveRegistryValue<bool?>(RegistryHive.CurrentUser, context.InstanceKey, "Foo").Should().BeTrue("successfully retrieved bool? as bool?");
                triState = null;
                Registry.SetRegistryValue(RegistryHive.CurrentUser, context.InstanceKey, "Foo", triState).Should().BeTrue("successfully set tristate bool as null");
                Registry.RetrieveRegistryValue<bool?>(RegistryHive.CurrentUser, context.InstanceKey, "Foo").Should().NotHaveValue("successfully retrieved bool? as null bool?");

                Registry.GetSubkeyNames(RegistryHive.CurrentUser, context.InstanceKey).Should().HaveCount(2);
            }
        }
Ejemplo n.º 7
0
 public void GetAllSubkeysTest_SubKeysNoValues()
 {
     using (RegistryTestContext context = new RegistryTestContext())
     {
         Registry.RetrieveAllRegistrySubkeyValues<string>(RegistryHive.CurrentUser, context.InstanceKey).Should().BeEmpty();
     }
 }
Ejemplo n.º 8
0
 public void GetAllSubkeysTest_SubKeysValues()
 {
     using (RegistryTestContext context = new RegistryTestContext())
     {
         Registry.SetRegistryValue<string>(RegistryHive.CurrentUser, context.InstanceKey + @"\Foo", "Foo1", "one");
         Registry.SetRegistryValue<string>(RegistryHive.CurrentUser, context.InstanceKey + @"\Foo", "Foo2", "two");
         Registry.SetRegistryValue<string>(RegistryHive.CurrentUser, context.InstanceKey + @"\Bar", null, "three");
         Registry.RetrieveAllRegistrySubkeyValues<string>(RegistryHive.CurrentUser, context.InstanceKey).Should().BeEquivalentTo("one", "two", "three");
     }
 }