Skip to content

Commit

Permalink
NCBC-93: ConfigHelper tests should use app.config
Browse files Browse the repository at this point in the history
Change-Id: I12dec591486c2423718a7e3d0b56071edc4d6c2b
Reviewed-on: http://review.couchbase.org/20530
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: John C. Zablocki <john@couchbase.com>
  • Loading branch information
jzablocki authored and John C. Zablocki committed Sep 11, 2012
1 parent 53180b4 commit c0f2ad9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/Couchbase.Tests/App.config
Expand Up @@ -3,6 +3,8 @@
<configSections>
<section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="min-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="pools-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="pools-default-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<sectionGroup name="enyim.com">
<section name="log" type="Enyim.Caching.Configuration.LoggerSection, Enyim.Caching" />
</sectionGroup>
Expand Down Expand Up @@ -44,4 +46,16 @@
<add uri="http://localhost:8091/pools" />
</servers>
</min-config>

<pools-config>
<servers bucket="default">
<add uri="http://localhost:8091/pools" />
</servers>
</pools-config>

<pools-default-config>
<servers bucket="default">
<add uri="http://localhost:8091/pools/default" />
</servers>
</pools-default-config>
</configuration>
11 changes: 3 additions & 8 deletions src/Couchbase.Tests/ConfigHelperTests.cs
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using Couchbase.Configuration;
using Enyim.Caching.Memcached;
using Couchbase.Tests.Utils;

namespace Couchbase.Tests
{
Expand All @@ -14,10 +15,7 @@ public class ConfigHelperTests : CouchbaseClientTestsBase
[Test]
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools"));
config.Bucket = "default";

var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("pools-config");
var client = new CouchbaseClient(config);

string key = GetUniqueKey(), value = GetRandomString();
Expand All @@ -32,10 +30,7 @@ public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri()
[Test]
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Default_Root_Uri()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/default"));
config.Bucket = "default";

var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("pools-default-config");
var client = new CouchbaseClient(config);

string key = GetUniqueKey(), value = GetRandomString();
Expand Down
1 change: 1 addition & 0 deletions src/Couchbase.Tests/Couchbase.Tests.csproj
Expand Up @@ -87,6 +87,7 @@
<Compile Include="HelperTests\JsonHelperTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="HelperTests\UriHelperTests.cs" />
<Compile Include="Utils\ConfigSectionUtils.cs" />
<Compile Include="Utils\KeyValueUtils.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
37 changes: 37 additions & 0 deletions src/Couchbase.Tests/Utils/ConfigSectionUtils.cs
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Couchbase.Tests.Utils
{
public static class ConfigSectionUtils
{
public static T GetConfigSection<T>(string name) where T : class
{
return ConfigurationManager.GetSection(name) as T;
}
}
}

#region [ License information ]
/* ************************************************************
*
* @author Couchbase <info@couchbase.com>
* @copyright 2012 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ************************************************************/
#endregion

0 comments on commit c0f2ad9

Please sign in to comment.