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


C# AppSettings.GetConnectionString方法代码示例

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


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

示例1: And_connection_string_exists_Then_existing_connection_string_should_be_replaced

        public void And_connection_string_exists_Then_existing_connection_string_should_be_replaced()
        {
            var settings = new AppSettings("NonExistingFile", FileOption.None);

            // Original value
            settings.SetConnectionString("cs", "a");
            Assert.AreEqual("a", settings.GetConnectionString("cs"));

            // Save with different value
            settings.SetConnectionString("cs", "b");

            Assert.AreEqual("b", settings.GetConnectionString("cs"));
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:13,代码来源:When_updating_ConnectionString.cs

示例2: And_connection_string_does_not_exist_Then_connection_string_should_be_stored

        public void And_connection_string_does_not_exist_Then_connection_string_should_be_stored()
        {
            var settings = new AppSettings("NonExistingFile", FileOption.None);
            settings.SetConnectionString("cs", "a");

            Assert.AreEqual("a", settings.GetConnectionString("cs"));
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:7,代码来源:When_updating_ConnectionString.cs

示例3: Then_connection_string_should_be_returned

        public void Then_connection_string_should_be_returned()
        {
            var settings = new AppSettings(SimpleConfig.AbsolutePathToConfigFile);

            var value = settings.GetConnectionString(SimpleConfig.ConnectionStringName);

            Assert.AreEqual(SimpleConfig.ConnectionString, value);
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:8,代码来源:When_Getting_ConnectionString_By_Name.cs

示例4: And_connection_string_does_not_exist_Then_exception_is_thrown

        public void And_connection_string_does_not_exist_Then_exception_is_thrown()
        {
            var settings = new AppSettings(SimpleConfig.AbsolutePathToConfigFile);

            Assert.Throws<AppSettingException>(() => settings.GetConnectionString("NonExistingConnectionString"));
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:6,代码来源:When_Getting_ConnectionString_By_Name.cs

示例5: And_IsConnectionString_is_true_then_setting_is_read_from_connection_strings

        public void And_IsConnectionString_is_true_then_setting_is_read_from_connection_strings()
        {
            var settings = new AppSettings(SimpleConfig.AbsolutePathToConfigFile);
            var mySettings = new SettingsWithConnectionString();

            settings.WriteInto(mySettings);

            var value = settings.GetConnectionString("MyDatabase");
            Assert.AreEqual(value, mySettings.DatabaseConnectionString);
            Assert.AreEqual("A", mySettings.OptionalConnectionString);
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:11,代码来源:When_SettingAttribute_is_defined.cs

示例6: And_IsConnectionString_is_true_then_setting_is_saved_as_connection_string

        public void And_IsConnectionString_is_true_then_setting_is_saved_as_connection_string()
        {
            var settings = new AppSettings("filename", FileOption.None);
            var mySettings = new SettingsWithConnectionString()
                {
                    DatabaseConnectionString = @"Data Source=localhost;Initial Catalog=MyDb;User Id=username;Password=password;"
                };

            settings.ReadFrom(mySettings);

            var value = settings.GetConnectionString("MyDb");
            Assert.AreEqual(value, mySettings.DatabaseConnectionString);
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:13,代码来源:When_SettingAttribute_is_defined.cs


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