diff --git a/.gitignore b/.gitignore index 2bf9f9b..2705fd1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ *.suo [Bb]in/ [Oo]bj/ -TestResults/ \ No newline at end of file +TestResults/ +_ReSharper* +packages/ +*.suo +*.user +*.sln.docstates \ No newline at end of file diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe new file mode 100644 index 0000000..2c93698 Binary files /dev/null and b/.nuget/NuGet.exe differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000..83fe906 --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,136 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CoderMike.Autofac.EasySettings.1.0.nuspec b/CoderMike.Autofac.EasySettings.1.0.nuspec index 5f9c865..57588ca 100644 --- a/CoderMike.Autofac.EasySettings.1.0.nuspec +++ b/CoderMike.Autofac.EasySettings.1.0.nuspec @@ -11,7 +11,7 @@ Constructing settings classes that get read out of AppSettings on demand - + \ No newline at end of file diff --git a/CoderMike.Autofac.EasySettings.Tests/App.config b/CoderMike.Autofac.EasySettings.Tests/App.config index 0daa1a7..b2de2af 100644 --- a/CoderMike.Autofac.EasySettings.Tests/App.config +++ b/CoderMike.Autofac.EasySettings.Tests/App.config @@ -1,12 +1,20 @@ - + - - - + + + + + + + + + + + \ No newline at end of file diff --git a/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/DirectProviderSetupFixture.cs b/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/DirectProviderSetupFixture.cs new file mode 100644 index 0000000..7722c71 --- /dev/null +++ b/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/DirectProviderSetupFixture.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Autofac; + +using CoderMike.Autofac.EasySettings.Tests.SettingsReading; + +using Xunit; + +namespace CoderMike.Autofac.EasySettings.Tests.AutofacConfiguration +{ + public class DirectProviderSetupFixture + { + private readonly TestSettingsProvider _provider; + + public DirectProviderSetupFixture() + { + _provider = new TestSettingsProvider(new Dictionary + { + {"First:Value", "things"} + }); + } + + [Fact] + public void ModuleInstallsSimpleSettingsReaderByDefault() + { + var module = new EasySettingsModule(_provider); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + var reader = container.Resolve(); + + Assert.NotNull(reader); + Assert.IsType(reader); + } + + [Fact] + public void ModuleInstallsSettingsSource() + { + var module = new EasySettingsModule(_provider); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + Assert.NotEmpty(container.ComponentRegistry.Sources.OfType()); + } + + [Fact] + public void ConfigurationValuesLoadedFromSuppliedCollection() + { + var module = new EasySettingsModule(_provider); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + var reader = container.Resolve(); + + var instance = reader.Read(); + + Assert.Equal("things", instance.Value); + } + } +} \ No newline at end of file diff --git a/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/FileSetupFixture.cs b/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/FileSetupFixture.cs new file mode 100644 index 0000000..243190d --- /dev/null +++ b/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/FileSetupFixture.cs @@ -0,0 +1,57 @@ +using System; +using System.Linq; + +using Autofac; + +using CoderMike.Autofac.EasySettings.Tests.SettingsReading; + +using Xunit; + +namespace CoderMike.Autofac.EasySettings.Tests.AutofacConfiguration +{ + public class FileSetupFixture + { + [Fact] + public void ModuleInstallsSimpleSettingsReaderByDefault() + { + var module = new EasySettingsModule("MultipleEntries.json"); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + var reader = container.Resolve(); + + Assert.NotNull(reader); + Assert.IsType(reader); + } + + [Fact] + public void ModuleInstallsSettingsSource() + { + var module = new EasySettingsModule("MultipleEntries.json"); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + Assert.NotEmpty(container.ComponentRegistry.Sources.OfType()); + } + + [Fact] + public void ConfigurationValuesLoadedFromSuppliedCollection() + { + var module = new EasySettingsModule("MultipleEntries.json"); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + var reader = container.Resolve(); + + var instance = reader.Read(); + + Assert.Equal("blah", instance.Value); + } + } +} \ No newline at end of file diff --git a/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/NameValueCollectionSetupFixture.cs b/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/NameValueCollectionSetupFixture.cs new file mode 100644 index 0000000..8f8d326 --- /dev/null +++ b/CoderMike.Autofac.EasySettings.Tests/AutofacConfiguration/NameValueCollectionSetupFixture.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Specialized; +using System.Linq; + +using Autofac; + +using CoderMike.Autofac.EasySettings.Tests.SettingsReading; + +using Xunit; + +namespace CoderMike.Autofac.EasySettings.Tests.AutofacConfiguration +{ + public class NameValueCollectionSetupFixture + { + [Fact] + public void ModuleInstallsSimpleSettingsReaderByDefault() + { + var settings = new NameValueCollection(); + var module = new EasySettingsModule(settings); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + var reader = container.Resolve(); + + Assert.NotNull(reader); + Assert.IsType(reader); + } + + [Fact] + public void ModuleInstallsSettingsSource() + { + var settings = new NameValueCollection(); + var module = new EasySettingsModule(settings); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + Assert.NotEmpty(container.ComponentRegistry.Sources.OfType()); + } + + [Fact] + public void ConfigurationValuesLoadedFromSuppliedCollection() + { + var settings = new NameValueCollection + { + { "First:Value", "something"} + }; + var module = new EasySettingsModule(settings); + + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + var reader = container.Resolve(); + + var instance = reader.Read(); + + Assert.Equal("something", instance.Value); + } + } +} \ No newline at end of file diff --git a/CoderMike.Autofac.EasySettings.Tests/CoderMike.Autofac.EasySettings.Tests.csproj b/CoderMike.Autofac.EasySettings.Tests/CoderMike.Autofac.EasySettings.Tests.csproj index 2ec0147..ffaf554 100644 --- a/CoderMike.Autofac.EasySettings.Tests/CoderMike.Autofac.EasySettings.Tests.csproj +++ b/CoderMike.Autofac.EasySettings.Tests/CoderMike.Autofac.EasySettings.Tests.csproj @@ -14,6 +14,8 @@ v4.0 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\ + true true @@ -33,18 +35,21 @@ 4 - - ..\packages\Autofac.2.5.2.830\lib\NET40\Autofac.dll + + ..\packages\Autofac.3.1.1\lib\net40\Autofac.dll - - ..\packages\Autofac.2.5.2.830\lib\NET40\Autofac.Configuration.dll - - 3.5 + + + ..\packages\xunit.1.9.2\lib\net20\xunit.dll + + + ..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll + @@ -52,11 +57,17 @@ - + + + + + + - + + @@ -66,9 +77,31 @@ + + Always + + + Always + + + + + Always + + + + Always + + + Always + + + Always + +