コード例 #1
0
        public void LoadSettingsFromStorageDoesNotChangePropertiesWhenRegistryKeyDoesNotExist()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.LoadSettingsFromStorage();
            Assert.IsTrue(options.SyntaxColorizationEnabled);
        }
コード例 #2
0
        public void SaveSettingsToStorageCreatesNewRegistryKey()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.SaveSettingsToStorage();
            Assert.IsTrue(this.GetTestRegistryKey().GetSubKeyNames().Single() == "T4 Toolbox");
        }
コード例 #3
0
        public void ResetSettingsDisposesRootKey()
        {
            RegistryKey rootKey = this.GetTestRegistryKey();
            var         options = new TestableT4ToolboxOptions(() => rootKey);

            options.ResetSettings();
            rootKey.GetValueNames(); // ObjectDisposedException here
        }
コード例 #4
0
        public void ResetSettingsChangesPropertiesWithoutDefaultValueAttributeToDefaultTypeValue()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.BoolPropertyWithoutDefaultValueAttribute = true;
            options.ResetSettings();
            Assert.IsFalse(options.BoolPropertyWithoutDefaultValueAttribute);
        }
コード例 #5
0
        public void ResetSettingsChangesPropertiesToValuesSpecifiedInDefaultValueAttribute()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.SyntaxColorizationEnabled = false;
            options.ResetSettings();
            Assert.IsTrue(options.SyntaxColorizationEnabled);
        }
コード例 #6
0
 public void SaveSettingsToStorageUsesExistingRegistryKey()
 {
     using (RegistryKey existingKey = this.GetTestRegistryKey().CreateSubKey("T4 Toolbox"))
     {
         var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
         options.SaveSettingsToStorage();
         Assert.IsTrue(existingKey.GetValueNames().Any());
     }
 }
コード例 #7
0
 public void LoadSettingsFromStorageDoesNotChangePropertyWhenRegistryValueDoesNotExist()
 {
     using (RegistryKey rootKey = this.GetTestRegistryKey())
         using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
         {
             var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
             options.LoadSettingsFromStorage();
             Assert.IsTrue(options.SyntaxColorizationEnabled);
         }
 }
コード例 #8
0
        public void SaveSettingsToStorageWritesPropertyValuesToRegistryKey()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.SaveSettingsToStorage();
            using (RegistryKey rootKey = this.GetTestRegistryKey())
                using (RegistryKey settingsKey = rootKey.OpenSubKey("T4 Toolbox"))
                {
                    Assert.AreEqual(options.SyntaxColorizationEnabled.ToString(), settingsKey.GetValue("SyntaxColorizationEnabled"));
                }
        }
コード例 #9
0
 public void LoadSettingsFromStorageReadsPropertyValuesFromRegistryKey()
 {
     using (RegistryKey rootKey = this.GetTestRegistryKey())
         using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
         {
             settingsKey.SetValue("SyntaxColorizationEnabled", "False");
             var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
             options.LoadSettingsFromStorage();
             Assert.IsFalse(options.SyntaxColorizationEnabled);
         }
 }
コード例 #10
0
 public void LoadSettingsFromStorageConvertsRegistryValuesToPropertyTypeForBackwardCompatibility()
 {
     using (RegistryKey rootKey = this.GetTestRegistryKey())
         using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
         {
             settingsKey.SetValue("SyntaxColorizationEnabled", 0, RegistryValueKind.DWord);
             var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
             options.LoadSettingsFromStorage();
             Assert.IsFalse(options.SyntaxColorizationEnabled);
         }
 }
コード例 #11
0
        public void ResetSettingsDeletesRegistryKey()
        {
            using (RegistryKey rootKey = this.GetTestRegistryKey())
            {
                rootKey.CreateSubKey("T4 Toolbox");
            }

            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.ResetSettings();

            using (RegistryKey root = this.GetTestRegistryKey())
            {
                Assert.IsFalse(root.GetSubKeyNames().Any());
            }
        }
コード例 #12
0
        public void LoadSettingsFromStorageRaisesPropertyChangedEvent()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            using (RegistryKey rootKey = this.GetTestRegistryKey())
                using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
                {
                    settingsKey.SetValue("SyntaxColorizationEnabled", false, RegistryValueKind.DWord);
                }

            bool propertyChanged = false;

            options.PropertyChanged += (sender, args) => propertyChanged = true;
            options.LoadSettingsFromStorage();

            Assert.IsTrue(propertyChanged);
        }
コード例 #13
0
 public void ConstructorInitializesPropertiesWithoutDefaultValueAttribute()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     Assert.IsFalse(options.BoolPropertyWithoutDefaultValueAttribute);
 }
コード例 #14
0
 public void ResetSettingsChangesPropertiesToValuesSpecifiedInDefaultValueAttribute()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     options.SyntaxColorizationEnabled = false;
     options.ResetSettings();
     Assert.IsTrue(options.SyntaxColorizationEnabled);
 }
コード例 #15
0
        public void LoadSettingsFromStorageRaisesPropertyChangedEvent()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            using (RegistryKey rootKey = this.GetTestRegistryKey())
            using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
            {
                settingsKey.SetValue("SyntaxColorizationEnabled", false, RegistryValueKind.DWord);                
            }

            bool propertyChanged = false;
            options.PropertyChanged += (sender, args) => propertyChanged = true;
            options.LoadSettingsFromStorage();

            Assert.IsTrue(propertyChanged);
        }
コード例 #16
0
 public void LoadSettingsFromStorageDoesNotChangePropertiesWhenRegistryKeyDoesNotExist()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     options.LoadSettingsFromStorage();
     Assert.IsTrue(options.SyntaxColorizationEnabled);
 }
コード例 #17
0
 public void LoadSettingsFromStorageDoesNotChangePropertyWhenRegistryValueDoesNotExist()
 {
     using (RegistryKey rootKey = this.GetTestRegistryKey())
     using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
     {
         var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
         options.LoadSettingsFromStorage();
         Assert.IsTrue(options.SyntaxColorizationEnabled);
     }
 }
コード例 #18
0
 public void LoadSettingsFromStorageConvertsRegistryValuesToPropertyTypeForBackwardCompatibility()
 {
     using (RegistryKey rootKey = this.GetTestRegistryKey())
     using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
     {
         settingsKey.SetValue("SyntaxColorizationEnabled", 0, RegistryValueKind.DWord);
         var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
         options.LoadSettingsFromStorage();
         Assert.IsFalse(options.SyntaxColorizationEnabled);
     }
 }
コード例 #19
0
 public void SaveSettingsToStorageWritesPropertyValuesToRegistryKey()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     options.SaveSettingsToStorage();
     using (RegistryKey rootKey = this.GetTestRegistryKey())
     using (RegistryKey settingsKey = rootKey.OpenSubKey("T4 Toolbox"))
     {
         Assert.AreEqual(options.SyntaxColorizationEnabled.ToString(), settingsKey.GetValue("SyntaxColorizationEnabled"));
     }
 }
コード例 #20
0
 public void SaveSettingsToStorageUsesExistingRegistryKey()
 {
     using (RegistryKey existingKey = this.GetTestRegistryKey().CreateSubKey("T4 Toolbox"))
     {
         var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
         options.SaveSettingsToStorage();
         Assert.IsTrue(existingKey.GetValueNames().Any());
     }
 }
コード例 #21
0
 public void ResetSettingsDoesNotThrowWhenRegistryKeyDoesNotExist()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     options.ResetSettings();
 }
コード例 #22
0
        public void ResetSettingsDoesNotThrowWhenRegistryKeyDoesNotExist()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            options.ResetSettings();
        }
コード例 #23
0
 public void ResetSettingsChangesPropertiesWithoutDefaultValueAttributeToDefaultTypeValue()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     options.BoolPropertyWithoutDefaultValueAttribute = true;
     options.ResetSettings();
     Assert.IsFalse(options.BoolPropertyWithoutDefaultValueAttribute);            
 }
コード例 #24
0
 public void LoadSettingsFromStorageReadsPropertyValuesFromRegistryKey()
 {
     using (RegistryKey rootKey = this.GetTestRegistryKey())
     using (RegistryKey settingsKey = rootKey.CreateSubKey("T4 Toolbox"))
     {
         settingsKey.SetValue("SyntaxColorizationEnabled", "False");
         var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
         options.LoadSettingsFromStorage();
         Assert.IsFalse(options.SyntaxColorizationEnabled);
     }
 }
コード例 #25
0
        public void ResetSettingsDeletesRegistryKey()
        {
            using (RegistryKey rootKey = this.GetTestRegistryKey())
            {
                rootKey.CreateSubKey("T4 Toolbox");
            }

            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
            options.ResetSettings();

            using (RegistryKey root = this.GetTestRegistryKey())
            {
                Assert.IsFalse(root.GetSubKeyNames().Any());
            }
        }
コード例 #26
0
        public void ConstructorInitializesPropertiesWithoutDefaultValueAttribute()
        {
            var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);

            Assert.IsFalse(options.BoolPropertyWithoutDefaultValueAttribute);
        }
コード例 #27
0
 public void ResetSettingsDisposesRootKey()
 {
     RegistryKey rootKey = this.GetTestRegistryKey();
     var options = new TestableT4ToolboxOptions(() => rootKey);
     options.ResetSettings();
     rootKey.GetValueNames(); // ObjectDisposedException here            
 }
コード例 #28
0
 public void SaveSettingsToStorageCreatesNewRegistryKey()
 {
     var options = new TestableT4ToolboxOptions(this.GetTestRegistryKey);
     options.SaveSettingsToStorage();
     Assert.IsTrue(this.GetTestRegistryKey().GetSubKeyNames().Single() == "T4 Toolbox");
 }