Skip to content

Commit 1406f11

Browse files
Initial commit
0 parents  commit 1406f11

33 files changed

+1309
-0
lines changed

.gitignore

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
build/
21+
bld/
22+
[Bb]in/
23+
[Oo]bj/
24+
25+
# Visual Studio 2015 cache/options directory
26+
.vs/
27+
# Uncomment if you have tasks that create the project's static files in wwwroot
28+
#wwwroot/
29+
30+
# MSTest test Results
31+
[Tt]est[Rr]esult*/
32+
[Bb]uild[Ll]og.*
33+
34+
# NUNIT
35+
*.VisualState.xml
36+
TestResult.xml
37+
38+
# Build Results of an ATL Project
39+
[Dd]ebugPS/
40+
[Rr]eleasePS/
41+
dlldata.c
42+
43+
# DNX
44+
project.lock.json
45+
artifacts/
46+
47+
*_i.c
48+
*_p.c
49+
*_i.h
50+
*.ilk
51+
*.meta
52+
*.obj
53+
*.pch
54+
*.pdb
55+
*.pgc
56+
*.pgd
57+
*.rsp
58+
*.sbr
59+
*.tlb
60+
*.tli
61+
*.tlh
62+
*.tmp
63+
*.tmp_proj
64+
*.log
65+
*.vspscc
66+
*.vssscc
67+
.builds
68+
*.pidb
69+
*.svclog
70+
*.scc
71+
72+
# Chutzpah Test files
73+
_Chutzpah*
74+
75+
# Visual C++ cache files
76+
ipch/
77+
*.aps
78+
*.ncb
79+
*.opendb
80+
*.opensdf
81+
*.sdf
82+
*.cachefile
83+
84+
# Visual Studio profiler
85+
*.psess
86+
*.vsp
87+
*.vspx
88+
*.sap
89+
90+
# TFS 2012 Local Workspace
91+
$tf/
92+
93+
# Guidance Automation Toolkit
94+
*.gpState
95+
96+
# ReSharper is a .NET coding add-in
97+
_ReSharper*/
98+
*.[Rr]e[Ss]harper
99+
*.DotSettings.user
100+
101+
# JustCode is a .NET coding add-in
102+
.JustCode
103+
104+
# TeamCity is a build add-in
105+
_TeamCity*
106+
107+
# DotCover is a Code Coverage Tool
108+
*.dotCover
109+
110+
# NCrunch
111+
_NCrunch_*
112+
.*crunch*.local.xml
113+
nCrunchTemp_*
114+
115+
# MightyMoose
116+
*.mm.*
117+
AutoTest.Net/
118+
119+
# Web workbench (sass)
120+
.sass-cache/
121+
122+
# Installshield output folder
123+
[Ee]xpress/
124+
125+
# DocProject is a documentation generator add-in
126+
DocProject/buildhelp/
127+
DocProject/Help/*.HxT
128+
DocProject/Help/*.HxC
129+
DocProject/Help/*.hhc
130+
DocProject/Help/*.hhk
131+
DocProject/Help/*.hhp
132+
DocProject/Help/Html2
133+
DocProject/Help/html
134+
135+
# Click-Once directory
136+
publish/
137+
138+
# Publish Web Output
139+
*.[Pp]ublish.xml
140+
*.azurePubxml
141+
# TODO: Comment the next line if you want to checkin your web deploy settings
142+
# but database connection strings (with potential passwords) will be unencrypted
143+
*.pubxml
144+
*.publishproj
145+
146+
# NuGet Packages
147+
*.nupkg
148+
# The packages folder can be ignored because of Package Restore
149+
**/packages/*
150+
# except build/, which is used as an MSBuild target.
151+
!**/packages/build/
152+
# Uncomment if necessary however generally it will be regenerated when needed
153+
#!**/packages/repositories.config
154+
155+
# Windows Azure Build Output
156+
csx/
157+
*.build.csdef
158+
159+
# Windows Azure Emulator
160+
ecf/
161+
rcf/
162+
163+
# Windows Store app package directory
164+
AppPackages/
165+
166+
# Visual Studio cache files
167+
# files ending in .cache can be ignored
168+
*.[Cc]ache
169+
# but keep track of directories ending in .cache
170+
!*.[Cc]ache/
171+
172+
# Others
173+
ClientBin/
174+
[Ss]tyle[Cc]op.*
175+
~$*
176+
*~
177+
*.dbmdl
178+
*.dbproj.schemaview
179+
*.pfx
180+
*.publishsettings
181+
node_modules/
182+
orleans.codegen.cs
183+
184+
# RIA/Silverlight projects
185+
Generated_Code/
186+
187+
# Backup & report files from converting an old project file
188+
# to a newer Visual Studio version. Backup files are not needed,
189+
# because we have git ;-)
190+
_UpgradeReport_Files/
191+
Backup*/
192+
UpgradeLog*.XML
193+
UpgradeLog*.htm
194+
195+
# SQL Server files
196+
*.mdf
197+
*.ldf
198+
199+
# Business Intelligence projects
200+
*.rdl.data
201+
*.bim.layout
202+
*.bim_*.settings
203+
204+
# Microsoft Fakes
205+
FakesAssemblies/
206+
207+
# GhostDoc plugin setting file
208+
*.GhostDoc.xml
209+
210+
# Node.js Tools for Visual Studio
211+
.ntvs_analysis.dat
212+
213+
# Visual Studio 6 build log
214+
*.plg
215+
216+
# Visual Studio 6 workspace options file
217+
*.opt
218+
219+
# Visual Studio LightSwitch build output
220+
**/*.HTMLClient/GeneratedArtifacts
221+
**/*.DesktopClient/GeneratedArtifacts
222+
**/*.DesktopClient/ModelManifest.xml
223+
**/*.Server/GeneratedArtifacts
224+
**/*.Server/ModelManifest.xml
225+
_Pvt_Extensions
226+
227+
# Paket dependency manager
228+
.paket/paket.exe
229+
230+
# FAKE - F# Make
231+
.fake/

DynamicSettings.Tests/App.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<appSettings>
4+
<add key="TestSetting1" value="TestSetting1Value" />
5+
<add key="TestSetting2" value="TestSetting2Value" />
6+
</appSettings>
7+
</configuration>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
namespace DynamicSettings.Tests
2+
{
3+
using System.Collections.Generic;
4+
using FakeItEasy;
5+
using NUnit.Framework;
6+
7+
public class AppSettingsTests
8+
{
9+
[Test]
10+
public void AllReturnsAllSettings()
11+
{
12+
var fakeSettings1 = A.Fake<ISettings>();
13+
var fakeSettings2 = A.Fake<ISettings>();
14+
A.CallTo(() => fakeSettings1.GetAll()).Returns(new Dictionary<string, string> { { "TestSetting1", "TestSetting1Value" }});
15+
A.CallTo(() => fakeSettings2.GetAll()).Returns(new Dictionary<string, string> { { "TestSetting2", "TestSetting2Value" } });
16+
var appSettings = new AppSettings(fakeSettings1, fakeSettings2);
17+
18+
var result = appSettings.All;
19+
20+
Assert.AreEqual(2, result.Count);
21+
Assert.AreEqual("TestSetting1Value", result["TestSetting1"]);
22+
Assert.AreEqual("TestSetting2Value", result["TestSetting2"]);
23+
}
24+
25+
[Test]
26+
public void AllDoesNotReturnPrivateSettings()
27+
{
28+
var fakeSettings1 = A.Fake<ISettings>();
29+
var fakeSettings2 = A.Fake<ISettings>();
30+
A.CallTo(() => fakeSettings1.GetAll()).Returns(new Dictionary<string, string> { { "TestSetting1", "TestSetting1Value" } });
31+
A.CallTo(() => fakeSettings2.GetAll()).Returns(new Dictionary<string, string> { { "PrivateTestSetting2", "TestSetting2Value" } });
32+
var appSettings = new AppSettings(fakeSettings1, fakeSettings2);
33+
34+
var result = appSettings.All;
35+
36+
Assert.AreEqual(1, result.Count);
37+
Assert.AreEqual("TestSetting1Value", result["TestSetting1"]);
38+
Assert.IsFalse(result.ContainsKey("PrivateTestSetting2"));
39+
}
40+
41+
[Test]
42+
public void ReturnsCorrectSingleSetting()
43+
{
44+
var fakeSettings1 = A.Fake<ISettings>();
45+
var fakeSettings2 = A.Fake<ISettings>();
46+
A.CallTo(() => fakeSettings1.Get("TestSetting1")).Returns("TestSetting1Value");
47+
dynamic appSettings = new AppSettings(fakeSettings1, fakeSettings2);
48+
49+
var result = appSettings.TestSetting1;
50+
51+
Assert.AreEqual("TestSetting1Value", result);
52+
}
53+
}
54+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace DynamicSettings.Tests
2+
{
3+
using NUnit.Framework;
4+
5+
public class ConfigurationManagerSettingsTest
6+
{
7+
[Test]
8+
public void GetReturnsCorrectValue()
9+
{
10+
var settings = new ConfigurationManagerSettings();
11+
12+
var result = settings.Get("TestSetting1");
13+
14+
Assert.AreEqual("TestSetting1Value", result);
15+
}
16+
17+
[Test]
18+
public void GetAllReturnsCorrectValue()
19+
{
20+
var settings = new ConfigurationManagerSettings();
21+
22+
var result = settings.GetAll();
23+
24+
Assert.AreEqual("TestSetting1Value", result["TestSetting1"]);
25+
Assert.AreEqual("TestSetting2Value", result["TestSetting2"]);
26+
}
27+
}
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace DynamicSettings.Tests
2+
{
3+
using NUnit.Framework;
4+
5+
public class ConstantSettingsTest
6+
{
7+
[Test]
8+
public void GetsAndSetsValues()
9+
{
10+
var constantSettings = new TestSettings();
11+
12+
var setting1 = constantSettings.Get("Setting1");
13+
var setting2 = constantSettings.Get("Setting2");
14+
15+
Assert.AreEqual("Setting1Value", setting1);
16+
Assert.AreEqual("Setting2Value", setting2);
17+
}
18+
19+
[Test]
20+
public void GetsAllValues()
21+
{
22+
var constantSettings = new TestSettings();
23+
24+
var result = constantSettings.GetAll();
25+
26+
Assert.AreEqual("Setting1Value", result["Setting1"]);
27+
Assert.AreEqual("Setting2Value", result["Setting2"]);
28+
}
29+
30+
internal class TestSettings : ConstantSettings
31+
{
32+
protected override void InitializeValues()
33+
{
34+
Set("Setting1", "Setting1Value");
35+
Set("Setting2", "Setting2Value");
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)