当前位置: 首页>>代码示例>>C#>>正文


C# Settings.GetSettingValues方法代码示例

本文整理汇总了C#中Settings.GetSettingValues方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.GetSettingValues方法的具体用法?C# Settings.GetSettingValues怎么用?C# Settings.GetSettingValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings的用法示例。


在下文中一共展示了Settings.GetSettingValues方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CallingGetSettingValuesWithNullSectionWillThrowException

        public void CallingGetSettingValuesWithNullSectionWillThrowException()
        {
            // Arrange
            const string configFile = "NuGet.Config";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(configFile, mockBaseDirectory, @"<configuration></configuration>");
            var settings = new Settings(mockBaseDirectory);

            // Act & Assert
            Exception ex = Record.Exception(() => settings.GetSettingValues(null));
            Assert.NotNull(ex);
            var tex = Assert.IsAssignableFrom<ArgumentException>(ex);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:13,代码来源:SettingsTests.cs

示例2: GetValuesThrowsIfSettingsIsMissingKeys

        public void GetValuesThrowsIfSettingsIsMissingKeys()
        {
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageSources>
<add key="""" value=""C:\Temp\Nuget"" />
</packageSources>
<activePackageSource>
<add key=""test2"" value=""C:\Temp\Nuget"" />
</activePackageSource>
</configuration>";
            var nugetConfigPath = "NuGet.config";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act and Assert
            Exception ex = Record.Exception(() => settings.GetSettingValues("packageSources"));
            Assert.NotNull(ex);
            var tex = Assert.IsAssignableFrom<InvalidDataException>(ex);
            Assert.Equal(String.Format("Unable to parse config file '{0}'.", Path.Combine(mockBaseDirectory, nugetConfigPath)), ex.Message);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:22,代码来源:SettingsTests.cs

示例3: CallingGetValuesWithSectionReturnsDictionary

        public void CallingGetValuesWithSectionReturnsDictionary()
        {
            // Arrange
            var nugetConfigPath = "NuGet.Config";
            var config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
        <add key='key2' value='value2' />
    </SectionName>
</configuration>";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act
            var result = settings.GetSettingValues("SectionName");

            // Assert 
            Assert.NotNull(result);
            Assert.Equal(2, result.Count);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:22,代码来源:SettingsTests.cs

示例4: CallingGetValuesWithSectionWithInvalidAddItemsThrows

        public void CallingGetValuesWithSectionWithInvalidAddItemsThrows()
        {
            // Arrange
            var config = @"
<configuration>
    <SectionName>
        <add Key='key2' Value='value2' />
    </SectionName>
</configuration>";
            var nugetConfigPath = "NuGet.config";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act and Assert
            Exception ex = Record.Exception(() => settings.GetSettingValues("SectionName"));
            Assert.NotNull(ex);
            var tex = Assert.IsAssignableFrom<InvalidDataException>(ex);
            Assert.Equal(String.Format("Unable to parse config file '{0}'.", Path.Combine(mockBaseDirectory, nugetConfigPath)), ex.Message);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:20,代码来源:SettingsTests.cs

示例5: UserSetting_CallingGetValuesWithNonExistantSectionReturnsEmpty

        public void UserSetting_CallingGetValuesWithNonExistantSectionReturnsEmpty()
        {
            // Arrange
            const string configFile = "NuGet.Config";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(configFile, mockBaseDirectory, @"<configuration></configuration>");
            Settings settings = new Settings(mockBaseDirectory);

            // Act
            var result = settings.GetSettingValues("DoesNotExisit");

            // Assert 
            Assert.Empty(result);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:14,代码来源:SettingsTests.cs

示例6: GetValuesWithIsPathTrue

        public void GetValuesWithIsPathTrue()
        {
            // Arrange
            var nugetConfigPath = "NuGet.Config";
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <SectionName>
    <!-- values that are relative paths -->
    <add key=""key1"" value=""..\value1"" />
    <add key=""key2"" value=""a\b\c"" />
    <add key=""key3"" value="".\a\b\c"" />

    <!-- values that are not relative paths -->
    <add key=""key4"" value=""c:\value2"" />
    <add key=""key5"" value=""http://value3"" />    
    <add key=""key6"" value=""\\a\b\c"" />
    <add key=""key7"" value=""\a\b\c"" />
  </SectionName>
</configuration>";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act
            var result = settings.GetSettingValues("SectionName", isPath: true);

            // Assert
            AssertEqualCollections(
                result,
                new[]
                    {
                        "key1", String.Format(@"{0}\..\value1", mockBaseDirectory),
                        "key2", String.Format(@"{0}\a\b\c", mockBaseDirectory),
                        "key3", String.Format(@"{0}\.\a\b\c", mockBaseDirectory),
                        "key4", @"c:\value2",
                        "key5", @"http://value3",
                        "key6", @"\\a\b\c",
                        "key7", @"\a\b\c"
                    });
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:40,代码来源:SettingsTests.cs

示例7: GetValuesIgnoresClearedValues

        public void GetValuesIgnoresClearedValues()
        {
            // Arrange
            var nugetConfigPath = "NuGet.Config";
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <SectionName>
    <add key=""key1"" value=""value1"" />
    <add key=""key2"" value=""value2"" />
    <clear />
    <add key=""key3"" value=""value3"" />
    <add key=""key4"" value=""value4"" />
  </SectionName>
</configuration>";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act
            var result = settings.GetSettingValues("SectionName");

            // Assert
            AssertEqualCollections(result, new[] { "key3", "value3", "key4", "value4" });
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:24,代码来源:SettingsTests.cs

示例8: GetValuesWithIsPathTrue

        public void GetValuesWithIsPathTrue()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem(@"c:\root");
            var nugetConfigPath = "NuGet.Config";
            string config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <SectionName>
    <!-- values that are relative paths -->
    <add key=""key1"" value=""..\value1"" />
    <add key=""key2"" value=""a\b\c"" />
    <add key=""key3"" value="".\a\b\c"" />

    <!-- values that are not relative paths -->
    <add key=""key4"" value=""c:\value2"" />
    <add key=""key5"" value=""http://value3"" />    
    <add key=""key6"" value=""\\a\b\c"" />
    <add key=""key7"" value=""\a\b\c"" />
  </SectionName>
</configuration>";
            mockFileSystem.AddFile(nugetConfigPath, config);
            Settings settings = new Settings(mockFileSystem);

            // Act
            var result = settings.GetSettingValues("SectionName", isPath: true)
                .Select(v => new KeyValuePair<string, string>(v.Key, v.Value))
                .ToList();

            // Assert
            AssertEqualCollections(
                result, 
                new[] { 
                    "key1", @"c:\root\..\value1",
                    "key2", @"c:\root\a\b\c",
                    "key3", @"c:\root\.\a\b\c",

                    "key4", @"c:\value2",
                    "key5", @"http://value3",
                    "key6", @"\\a\b\c",
                    "key7", @"\a\b\c"
                });
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:42,代码来源:SettingsTests.cs


注:本文中的Settings.GetSettingValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。