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


C# Settings.GetValues方法代码示例

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


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

示例1: UserSettings_CallingGetValuesWithNullSectionWillThrowException

 public void UserSettings_CallingGetValuesWithNullSectionWillThrowException()
 {
     // Arrange 
     var mockFileSystem = new Mock<IFileSystem>();
     var settings = new Settings(mockFileSystem.Object);
     // Act & Assert
     ExceptionAssert.Throws<ArgumentException>(() => settings.GetValues(null));
 }
开发者ID:monoman,项目名称:NugetCracker,代码行数:8,代码来源:UserSettingsTests.cs

示例2: GetValuesIgnoresClearedValues

        public void GetValuesIgnoresClearedValues()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem();
            var nugetConfigPath = "NuGet.Config";
            string 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>";
            mockFileSystem.AddFile(nugetConfigPath, config);
            Settings settings = new Settings(mockFileSystem);

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

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

示例3: UserSetting_CallingGetValuesWithNonExistantSectionReturnsEmpty

        public void UserSetting_CallingGetValuesWithNonExistantSectionReturnsEmpty()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem();
            var nugetConfigPath = "NuGet.Config";
            
            string config = @"<configuration></configuration>";
            mockFileSystem.AddFile(nugetConfigPath, config);
            Settings settings = new Settings(mockFileSystem);

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

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

示例4: CallingGetValuesWithSectionReturnsDictionary

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

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

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

示例5: CallingGetValuesWithoutSectionReturnsEmptyList

        public void CallingGetValuesWithoutSectionReturnsEmptyList()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem();
            var nugetConfigPath = "NuGet.Config";
            string config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
        <add key='key2' value='value2' />
    </SectionName>
</configuration>";
            mockFileSystem.AddFile(nugetConfigPath, config);
            Settings settings = new Settings(mockFileSystem);

            // Act
            var result = settings.GetValues("NotTheSectionName");

            // Arrange 
            Assert.Empty(result);
        }
开发者ID:Redth,项目名称:nuget,代码行数:21,代码来源:SettingsTests.cs

示例6: 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 mockFileSystem = new MockFileSystem(@"x:\test");
            mockFileSystem.AddFile(nugetConfigPath, config.AsStream());
            Settings settings = new Settings(mockFileSystem);

            // Act and Assert
            ExceptionAssert.Throws<InvalidDataException>(() => settings.GetValues("packageSources"), @"Unable to parse config file 'x:\test\NuGet.Config'.");
        }
开发者ID:Redth,项目名称:nuget,代码行数:19,代码来源:SettingsTests.cs

示例7: CallingGetValuesWithSectionWithInvalidAddItemsThrows

        public void CallingGetValuesWithSectionWithInvalidAddItemsThrows()
        {
            // Arrange
            var config = @"
<configuration>
    <SectionName>
        <add Key='key2' Value='value2' />
    </SectionName>
</configuration>";
            var nugetConfigPath = "NuGet.Config";
            var mockFileSystem = new MockFileSystem(@"x:\test");
            mockFileSystem.AddFile(nugetConfigPath, config.AsStream());
            Settings settings = new Settings(mockFileSystem);

            // Act and Assert
            ExceptionAssert.Throws<InvalidDataException>(() => settings.GetValues("SectionName"), @"Unable to parse config file 'x:\test\NuGet.Config'.");
        }
开发者ID:Redth,项目名称:nuget,代码行数:17,代码来源: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.GetValues("SectionName", isPath: true);

            // 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:Redth,项目名称:nuget,代码行数:40,代码来源:SettingsTests.cs

示例9: UserSetting_CallingGetValuesWithNonExistantSectionReturnsNull

        public void UserSetting_CallingGetValuesWithNonExistantSectionReturnsNull()
        {
            // Arrange
            var mockFileSystem = new Mock<IFileSystem>();
            var nugetConfigPath = "NuGet.Config";
            mockFileSystem.Setup(m => m.FileExists(nugetConfigPath)).Returns(true);
            string config = @"<configuration></configuration>";
            mockFileSystem.Setup(m => m.OpenFile(nugetConfigPath)).Returns(config.AsStream());
            Settings settings = new Settings(mockFileSystem.Object);

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

            // Assert 
            Assert.Null(result);
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:16,代码来源:UserSettingsTests.cs

示例10: UserSettings_CallingGetValuesWithSectionReturnsDictionary

        public void UserSettings_CallingGetValuesWithSectionReturnsDictionary()
        {
            // Arrange
            var mockFileSystem = new Mock<IFileSystem>();
            var nugetConfigPath = "NuGet.Config";
            mockFileSystem.Setup(m => m.FileExists(nugetConfigPath)).Returns(true);
            string config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
        <add key='key2' value='value2' />
    </SectionName>
</configuration>";
            mockFileSystem.Setup(m => m.OpenFile(nugetConfigPath)).Returns(config.AsStream());
            Settings settings = new Settings(mockFileSystem.Object);

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

            // Assert 
            Assert.NotNull(result);
            Assert.Equal(2, result.Count);
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:23,代码来源:UserSettingsTests.cs


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