-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed up the AppSettingsProvider so that it actually works -- with UT…
…'s too!
- Loading branch information
1 parent
a49bac7
commit b50b36b
Showing
19 changed files
with
274 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/FubuCore.Testing/Configuration/AppSettingsKeyValuesTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using FubuCore.Configuration; | ||
using NUnit.Framework; | ||
using FubuTestingSupport; | ||
|
||
namespace FubuCore.Testing.Configuration | ||
{ | ||
[TestFixture] | ||
public class AppSettingsKeyValuesTester | ||
{ | ||
private AppSettingsKeyValues theValues; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
theValues = new AppSettingsKeyValues(); | ||
} | ||
|
||
[Test] | ||
public void contains_key() | ||
{ | ||
theValues.ContainsKey("AppSettings.Nested.Flag3").ShouldBeTrue(); | ||
theValues.ContainsKey("a").ShouldBeTrue(); | ||
theValues.ContainsKey("AppSettings.Nested.Files[1].Location").ShouldBeTrue(); | ||
|
||
|
||
theValues.ContainsKey("not a real value").ShouldBeFalse(); | ||
} | ||
|
||
[Test] | ||
public void get() | ||
{ | ||
theValues.Get("a").ShouldEqual("1"); | ||
theValues.Get("AppSettings.Flag1").ShouldEqual("f1"); | ||
} | ||
|
||
[Test] | ||
public void get_all_keys() | ||
{ | ||
var keys = theValues.GetKeys(); | ||
keys.ShouldContain("a"); | ||
keys.ShouldContain("b"); | ||
keys.ShouldContain("c"); | ||
keys.ShouldContain("AppSettings.Flag1"); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/FubuCore.Testing/Configuration/AppSettingsProviderIntegratedTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Collections.Generic; | ||
using FubuCore.Binding; | ||
using FubuCore.Configuration; | ||
using NUnit.Framework; | ||
using FubuTestingSupport; | ||
using System.Linq; | ||
|
||
namespace FubuCore.Testing.Configuration | ||
{ | ||
|
||
/****************************************** | ||
* | ||
* | ||
* See the FubuCore.Testing.dll.config file for the data | ||
* | ||
* | ||
******************************************/ | ||
|
||
[TestFixture] | ||
public class AppSettingsProviderIntegratedTester | ||
{ | ||
private AppSettings theSettings; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
theSettings = new AppSettingsProvider(ObjectResolver.Basic()) | ||
.SettingsFor<AppSettings>(); | ||
|
||
} | ||
|
||
[Test] | ||
public void can_get_basic_properties() | ||
{ | ||
theSettings.Flag1.ShouldEqual("f1"); | ||
theSettings.Flag2.ShouldEqual("f2"); | ||
} | ||
|
||
[Test] | ||
public void can_get_a_nested_object() | ||
{ | ||
theSettings.Nested.ShouldNotBeNull(); | ||
theSettings.Nested.Flag3.ShouldEqual("f3"); | ||
} | ||
|
||
[Test] | ||
public void can_build_enumeration_properties() | ||
{ | ||
theSettings.Nested.Files.Select(x => x.Name) | ||
.ShouldHaveTheSameElementsAs("control", "home"); | ||
} | ||
} | ||
|
||
public class AppSettings | ||
{ | ||
public string Flag1 { get; set; } | ||
public string Flag2 { get; set; } | ||
public NestedSetting Nested { get; set; } | ||
} | ||
|
||
public class NestedSetting | ||
{ | ||
public string Flag3 { get; set; } | ||
public IEnumerable<AppFile> Files { get; set; } | ||
} | ||
|
||
public class AppFile | ||
{ | ||
public string Name { get; set; } | ||
public string Location { get; set; } | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/FubuCore.Testing/Configuration/AppSettingsRequestDataIntegratedTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using FubuCore.Configuration; | ||
using NUnit.Framework; | ||
using FubuTestingSupport; | ||
|
||
namespace FubuCore.Testing.Configuration | ||
{ | ||
[TestFixture] | ||
public class AppSettingsRequestDataIntegratedTester | ||
{ | ||
private AppSettingsRequestData theData; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
theData = new AppSettingsRequestData(typeof(AppSettings)); | ||
} | ||
|
||
[Test] | ||
public void value() | ||
{ | ||
theData.Value("Flag1").ShouldEqual("f1"); | ||
theData.Value("Flag2").ShouldEqual("f2"); | ||
} | ||
|
||
[Test] | ||
public void value_of_complicated_values() | ||
{ | ||
theData.Value("NestedFlag3").ShouldEqual("f3"); | ||
} | ||
|
||
[Test] | ||
public void get_subrequest() | ||
{ | ||
theData.GetSubRequest("Nested").Value("Flag3").ShouldEqual("f3"); | ||
} | ||
|
||
[Test] | ||
public void get_enumerable_requests() | ||
{ | ||
theData.GetEnumerableRequests("NestedFiles").ShouldHaveCount(2); | ||
} | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
src/FubuCore.Testing/Configuration/OverrideSubstitutedRequestDataTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using FubuCore.Util; | ||
|
||
namespace FubuCore.Configuration | ||
{ | ||
public class AppSettingsKeyValues : IKeyValues | ||
{ | ||
public bool ContainsKey(string key) | ||
{ | ||
if (!ConfigurationManager.AppSettings.HasKeys()) | ||
{ | ||
return false; | ||
} | ||
|
||
return ConfigurationManager.AppSettings.AllKeys.Contains(key); | ||
} | ||
|
||
public string Get(string key) | ||
{ | ||
return ConfigurationManager.AppSettings[key]; | ||
} | ||
|
||
public IEnumerable<string> GetKeys() | ||
{ | ||
if (!ConfigurationManager.AppSettings.HasKeys()) | ||
{ | ||
return Enumerable.Empty<string>(); | ||
} | ||
|
||
return ConfigurationManager.AppSettings.AllKeys; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.