diff --git a/.travis.yml b/.travis.yml
index adcd92a..8cdb3a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,36 +1,24 @@
language: csharp
-sudo: required
branches:
except:
- /^[0-9]/
-addons:
- apt:
- packages:
- - gettext
- - libcurl4-openssl-dev
- - libicu-dev
- - libssl-dev
- - libunwind8
- - zlib1g
services:
- docker
env:
global:
- - CLI_VERSION: latest
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
-mono:
- - 4.0.5
-dotnet: 1.0.0-preview2-003121
-os:
- - linux
- - osx
-osx_image: xcode7.3
-before_install:
- - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s -f /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s -f /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi
+matrix:
+ include:
+ - os: linux
+ sudo: required
+ dotnet: 2.0.0
+ - os: osx
+ osx_image: xcode9 # OSX 10.12
+ dotnet: 2.0.0
script:
- git fetch --unshallow
- - if test "$TRAVIS_PULL_REQUEST" == "false"; then ./build.sh -v; else ./build.sh; fi
+ - ./build.sh
notifications:
on_success: always
on_failure: always
diff --git a/GitVersion.yml b/GitVersionConfig.yaml
similarity index 76%
rename from GitVersion.yml
rename to GitVersionConfig.yaml
index 6e83635..49265ca 100644
--- a/GitVersion.yml
+++ b/GitVersionConfig.yaml
@@ -1,42 +1,50 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
-
+
# It would be better to use smarter regexes instead of duplicating everything for local and remote cases.
# However, GitVersion has some built-in patterns which cannot be removed and these would cause clashes.
branches:
-
+
# These branch patterns cover all local cases
master:
+ regex: master
tag: master
increment: Minor
prevent-increment-of-merged-branch-version: true
- feature[/-]:
+ feature:
+ regex: feature[/-]
tag: a{BranchName}
increment: Minor
prevent-increment-of-merged-branch-version: false
- patch[/-]:
+ patch:
+ regex: patch[/-]
tag: useBranchName
increment: Patch
prevent-increment-of-merged-branch-version: false
- release[/-]:
+ release:
+ regex: release[/-]
tag: rc
increment: None
prevent-increment-of-merged-branch-version: false
-
+
# These branch patterns cover all remote cases
origin/master:
+ regex: origin/master
tag: master
increment: Minor
prevent-increment-of-merged-branch-version: true
- origin/feature[/-]:
+ origin/feature:
+ regex: origin/feature[/-]
tag: a{BranchName}
increment: Minor
prevent-increment-of-merged-branch-version: false
- origin/patch[/-]:
+ origin/patch:
+ regex: origin/patch[/-]
tag: useBranchName
increment: Patch
prevent-increment-of-merged-branch-version: false
- origin/release[/-]:
+ origin/release:
+ regex: origin/release[/-]
tag: rc
increment: None
prevent-increment-of-merged-branch-version: false
\ No newline at end of file
diff --git a/RuleSet.xml b/RuleSet.xml
deleted file mode 100644
index b374ee0..0000000
--- a/RuleSet.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Winton.Extensions.Configuration.Consul.sln b/Winton.Extensions.Configuration.Consul.sln
new file mode 100644
index 0000000..4c07096
--- /dev/null
+++ b/Winton.Extensions.Configuration.Consul.sln
@@ -0,0 +1,55 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26430.14
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{92E73150-9357-4AA6-8C7D-E43709B27A6D}"
+ ProjectSection(SolutionItems) = preProject
+ .travis.yml = .travis.yml
+ appveyor.yml = appveyor.yml
+ build.sh = build.sh
+ CONTRIBUTING.md = CONTRIBUTING.md
+ GitVersionConfig.yaml = GitVersionConfig.yaml
+ LICENSE = LICENSE
+ README.md = README.md
+ stylecop.json = stylecop.json
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{03739F78-2460-4F1E-92F2-807CBD8C8AB5}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{972A51CA-2686-4B9B-8BBB-503B2A1BA630}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Winton.Extensions.Configuration.Consul", "src\Winton.Extensions.Configuration.Consul\Winton.Extensions.Configuration.Consul.csproj", "{B5C08CE5-B60B-485F-B78F-A119B8AA8508}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Winton.Extensions.Configuration.Consul.Test", "test\Winton.Extensions.Configuration.Consul.Test\Winton.Extensions.Configuration.Consul.Test.csproj", "{6A8821FC-BE1A-4EC8-8A51-73105458CC85}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Website", "test\Website\Website.csproj", "{44386D3A-3926-410D-AAD6-3820E17D712A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B5C08CE5-B60B-485F-B78F-A119B8AA8508}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B5C08CE5-B60B-485F-B78F-A119B8AA8508}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B5C08CE5-B60B-485F-B78F-A119B8AA8508}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B5C08CE5-B60B-485F-B78F-A119B8AA8508}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A8821FC-BE1A-4EC8-8A51-73105458CC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A8821FC-BE1A-4EC8-8A51-73105458CC85}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A8821FC-BE1A-4EC8-8A51-73105458CC85}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A8821FC-BE1A-4EC8-8A51-73105458CC85}.Release|Any CPU.Build.0 = Release|Any CPU
+ {44386D3A-3926-410D-AAD6-3820E17D712A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {44386D3A-3926-410D-AAD6-3820E17D712A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {44386D3A-3926-410D-AAD6-3820E17D712A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {44386D3A-3926-410D-AAD6-3820E17D712A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {B5C08CE5-B60B-485F-B78F-A119B8AA8508} = {03739F78-2460-4F1E-92F2-807CBD8C8AB5}
+ {6A8821FC-BE1A-4EC8-8A51-73105458CC85} = {972A51CA-2686-4B9B-8BBB-503B2A1BA630}
+ {44386D3A-3926-410D-AAD6-3820E17D712A} = {972A51CA-2686-4B9B-8BBB-503B2A1BA630}
+ EndGlobalSection
+EndGlobal
diff --git a/appveyor.yml b/appveyor.yml
index 1d3f128..9cbe71c 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,20 +3,26 @@ environment:
CLI_VERSION: latest
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
+image: Visual Studio 2017
+configuration:
+ - Release
skip_tags: true
+before_build:
+ - dotnet restore
build_script:
- - ps: .\build.ps1 -VersionAndPublish (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER)
-test: off
+ - msbuild /p:GetVersion=True /p:WriteVersionInfoToBuildLog=True
+test_script:
+ - dotnet test test/Winton.Extensions.Configuration.Consul.Test/ --no-build --configuration Release
artifacts:
- path: .\**\*.nupkg
name: NuGet
nuget:
disable_publish_on_pr: true
-deploy:
+deploy:
- provider: NuGet
api_key:
secure: CxMH3k6k/Rpz1zjToGDAelLWDT/gDqRo08iEUAQsRnL+WRo+4TL5gLiNEUy/GfUy
on:
- branch:
+ branch:
- master
- - /release\/[0-9]\.[0-9]/
+ - /release\/[0-9]\.[0-9]/
\ No newline at end of file
diff --git a/build.ps1 b/build.ps1
deleted file mode 100755
index c0a4b03..0000000
--- a/build.ps1
+++ /dev/null
@@ -1,41 +0,0 @@
-# Taken from psake https://github.com/psake/psake and modified
-param(
- [Parameter(Position=0,Mandatory=0)][bool]$VersionAndPublish = $true
-)
-
-<#
-.SYNOPSIS
- This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
- to see if an error occcured. If an error is detected then an exception is thrown.
- This function allows you to run command-line programs without having to
- explicitly check the $lastexitcode variable.
-.EXAMPLE
- exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
-#>
-function Exec
-{
- [CmdletBinding()]
- param(
- [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
- [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
- )
- & $cmd
- if ($lastexitcode -ne 0)
- {
- throw ("Exec: " + $errorMessage)
- }
-}
-
-exec { & dotnet restore }
-cd src\Winton.Extensions.Configuration.Consul
-if ($VersionAndPublish)
-{
- exec { & dotnet gitversion }
-}
-cd ..\..\
-exec { & dotnet build src\*\project.json test\*\project.json --configuration Release }
-exec { & dotnet test --no-build --configuration Release -f netcoreapp1.0 test\Winton.Extensions.Configuration.Consul.Test\project.json }
-if ($VersionAndPublish)
-{
- exec { & dotnet pack --no-build src\Winton.Extensions.Configuration.Consul\project.json --configuration Release }
-}
\ No newline at end of file
diff --git a/build.sh b/build.sh
index f38380d..ac817e2 100755
--- a/build.sh
+++ b/build.sh
@@ -1,34 +1,17 @@
-set -e
+#! /bin/bash
-while getopts v option
-do
- case "${option}"
- in
- v) VERSION_AND_PUBLISH="true";;
- esac
-done
+set -e
# Restore packages
dotnet restore
-# Set version numbers
-if [[ $VERSION_AND_PUBLISH ]]; then
- echo "Versioning..."
- (cd src/Winton.Extensions.Configuration.Consul && dotnet gitversion)
-else
- echo "WARN: Skipping versioning."
-fi
-
# Build
-dotnet build src/Winton.Extensions.Configuration.Consul/project.json test/Winton.Extensions.Configuration.Consul.Test/project.json --configuration Release
+dotnet build --configuration Release
# Unit Test
-dotnet test --no-build --configuration Release -f netcoreapp1.0 test/Winton.Extensions.Configuration.Consul.Test/project.json
+dotnet test test/Winton.Extensions.Configuration.Consul.Test/ --no-build --configuration Release
# Integration test
if hash docker 2>/dev/null; then
./test/Website/IntegrationTests/run.sh
fi
-
-# Package
-dotnet pack --no-build src/*/project.json --configuration Release
diff --git a/global.json b/global.json
deleted file mode 100644
index e7b30ca..0000000
--- a/global.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "projects": [
- "src",
- "test"
- ]
-}
\ No newline at end of file
diff --git a/src/Winton.Extensions.Configuration.Consul/Properties/AssemblyInfo.cs b/src/Winton.Extensions.Configuration.Consul/Properties/AssemblyInfo.cs
index c250809..6d00308 100644
--- a/src/Winton.Extensions.Configuration.Consul/Properties/AssemblyInfo.cs
+++ b/src/Winton.Extensions.Configuration.Consul/Properties/AssemblyInfo.cs
@@ -3,6 +3,5 @@
using System.Runtime.CompilerServices;
-[assembly: InternalsVisibleTo("Winton.Extensions.Configuration.Consul.Test")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
-[assembly: InternalsVisibleTo("Website")]
+[assembly: InternalsVisibleTo("Winton.Extensions.Configuration.Consul.Test")]
\ No newline at end of file
diff --git a/src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.csproj b/src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.csproj
new file mode 100644
index 0000000..bbd52a2
--- /dev/null
+++ b/src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.csproj
@@ -0,0 +1,38 @@
+
+
+
+ Copyright (c) Winton
+ Provides support for configuring .Net Core applications with Consul
+ True
+ False
+ $(NoWarn);SA1101;SA1309;SA1413
+ Winton.Extensions.Configuration.Consul
+ https://github.com/wintoncode/Winton.Extensions.Configuration.Consul/blob/master/LICENSE
+ True
+ .Net;.Net Core;dotnetcore;Asp.Net;Asp.Net Core;aspnetcore;configuration;consul;winton;wintoncode
+ $(NuGetVersion)
+ git
+ https://github.com/wintoncode/Winton.Extensions.Configuration.Consul
+ netstandard1.3
+ True
+ False
+
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.xproj b/src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.xproj
deleted file mode 100644
index cb63b7b..0000000
--- a/src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.xproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- 14.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
-
-
- 805e8ed2-3be6-49e0-9427-e8ead137ffce
- .\obj
- .\bin\
-
-
- 2.0
-
-
\ No newline at end of file
diff --git a/src/Winton.Extensions.Configuration.Consul/project.json b/src/Winton.Extensions.Configuration.Consul/project.json
deleted file mode 100644
index 4c5ea61..0000000
--- a/src/Winton.Extensions.Configuration.Consul/project.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "buildOptions": {
- "additionalArguments": [ "/ruleset:../../RuleSet.xml", "/additionalfile:../../stylecop.json" ],
- "outputName": "Winton.Extensions.Configuration.Consul",
- "warningsAsErrors": true,
- "xmlDoc": true
- },
- "dependencies": {
- "Consul": "0.7.0.3",
- "Microsoft.Extensions.Configuration": "1.0.0",
- "Newtonsoft.Json": "9.0.1",
- "StyleCop.Analyzers": {
- "version": "1.1.0-beta001",
- "type": "build"
- }
- },
- "description": "Provides support for configuring .Net Core applications with Consul",
- "frameworks": {
- "net451": {},
- "netstandard1.3": {}
- },
- "name": "Winton.Extensions.Configuration.Consul",
- "packOptions": {
- "repository": {
- "type": "git",
- "url": "https://github.com/wintoncode/Winton.Extensions.Configuration.Consul"
- },
- "tags": [
- ".Net",
- ".Net Core",
- "dotnetcore",
- "Asp.Net",
- "Asp.Net Core",
- "aspnetcore",
- "configuration",
- "consul",
- "winton",
- "wintoncode"
- ]
- },
- "title": "Winton.Extensions.Configuration.Consul",
- "tools": {
- "dotnet-gitversion": {
- "version": "*",
- "imports": [
- "dotnet"
- ]
- }
- },
- "version": "0.0.0"
-}
\ No newline at end of file
diff --git a/stylecop.json b/stylecop.json
index 3d3299e..e2d3d81 100644
--- a/stylecop.json
+++ b/stylecop.json
@@ -1,5 +1,5 @@
{
- "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/1.1.0-beta001/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
+ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/1.0.2/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "Winton",
diff --git a/test/Website/Dockerfile b/test/Website/Dockerfile
index ca6c1b7..e050654 100644
--- a/test/Website/Dockerfile
+++ b/test/Website/Dockerfile
@@ -1,4 +1,4 @@
-FROM microsoft/dotnet:1.1.0-runtime
+FROM microsoft/dotnet:1.1.4-runtime
COPY bin/Release/netcoreapp1.1/publish /app
WORKDIR /app
@@ -6,4 +6,4 @@ WORKDIR /app
EXPOSE 80/tcp
ENV ASPNETCORE_URLS http://*:5000
-ENTRYPOINT ["dotnet", "Website.dll"]
+ENTRYPOINT ["dotnet", "Winton.Extensions.Configuration.Consul.Test.Website.dll"]
diff --git a/test/Website/IntegrationTests/run.sh b/test/Website/IntegrationTests/run.sh
index 4a983a2..4e16ebf 100755
--- a/test/Website/IntegrationTests/run.sh
+++ b/test/Website/IntegrationTests/run.sh
@@ -1,8 +1,14 @@
-workDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-dotnet publish $workDir/.. --configuration Release
-(cd $workDir && docker-compose rm -f)
-docker-compose -f $workDir/docker-compose.yml -p ci up --build --force-recreate -d
+#! /bin/bash
+
+pushd $( dirname $0 )
+
+dotnet publish ../ --configuration Release
+docker-compose rm -f
+docker-compose -f docker-compose.yml -p ci up --build --force-recreate -d
exitCode=$(docker wait ci_test_1)
docker logs -f ci_test_1
-(cd $workDir && docker-compose stop -t 1)
+docker-compose stop -t 1
+
+popd
+
exit $exitCode
diff --git a/test/Website/Program.cs b/test/Website/Program.cs
index 7af0e3e..edb725a 100755
--- a/test/Website/Program.cs
+++ b/test/Website/Program.cs
@@ -10,6 +10,7 @@ public static void Main(string[] args)
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
+ .UseIISIntegration()
.UseStartup()
.Build();
diff --git a/test/Website/Properties/launchSettings.json b/test/Website/Properties/launchSettings.json
new file mode 100644
index 0000000..2f02fc4
--- /dev/null
+++ b/test/Website/Properties/launchSettings.json
@@ -0,0 +1,20 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:51020/",
+ "sslPort": 44301
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Website/Startup.cs b/test/Website/Startup.cs
index b724321..68d3a66 100755
--- a/test/Website/Startup.cs
+++ b/test/Website/Startup.cs
@@ -11,50 +11,50 @@ namespace Winton.Extensions.Configuration.Consul.Website
public class Startup
{
private readonly CancellationTokenSource _consulConfigCancellationTokenSource = new CancellationTokenSource();
+ private readonly IConfigurationRoot _configuration;
public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory
- .AddConsole()
- .AddDebug();
-
- ILogger logger = loggerFactory.CreateLogger(nameof(Startup));
+ .AddConsole(LogLevel.Debug)
+ .AddDebug(LogLevel.Debug);
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddConsul(
- $"appsettings.json",
+ "appsettings.json",
_consulConfigCancellationTokenSource.Token,
- options => {
- options.ConsulConfigurationOptions = (cco) => {
+ options =>
+ {
+ options.ConsulConfigurationOptions = cco =>
+ {
cco.Address = new Uri("http://consul:8500");
};
options.Optional = true;
options.ReloadOnChange = true;
- options.OnLoadException = (exceptionContext) => {
+ options.OnLoadException = (exceptionContext) =>
+ {
exceptionContext.Ignore = true;
};
})
.AddEnvironmentVariables();
- Configuration = builder.Build();
+ _configuration = builder.Build();
}
- public IConfigurationRoot Configuration { get; }
-
public void ConfigureServices(IServiceCollection services)
{
services
- .AddSingleton(Configuration)
+ .AddSingleton(_configuration)
.AddMvc();
services.AddSwaggerGen();
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime)
+ public void Configure(IApplicationBuilder app, IApplicationLifetime appLifetime)
{
app
.UseMvc()
.UseSwagger()
- .UseSwaggerUi("api");
+ .UseSwaggerUi("swagger");
appLifetime.ApplicationStopping.Register(_consulConfigCancellationTokenSource.Cancel);
}
diff --git a/test/Website/Website.csproj b/test/Website/Website.csproj
new file mode 100644
index 0000000..ca36c90
--- /dev/null
+++ b/test/Website/Website.csproj
@@ -0,0 +1,34 @@
+
+
+
+ Winton.Extensions.Configuration.Consul.Test.Website
+ False
+ $(NoWarn);SA0001;SA1101;SA1309;SA1413;SA1600;SA1633;SA1652
+ Winton.Extensions.Configuration.Consul.Website
+ netcoreapp1.1
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/Website/project.json b/test/Website/project.json
deleted file mode 100755
index 065450d..0000000
--- a/test/Website/project.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "buildOptions": {
- "debugType": "portable",
- "emitEntryPoint": true,
- "preserveCompilationContext": true
- },
- "dependencies": {
- "Microsoft.NETCore.App": {
- "type": "platform",
- "version": "1.1.0"
- },
- "Microsoft.AspNetCore.Mvc": "1.1.0",
- "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
- "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
- "Microsoft.Extensions.Configuration.Json": "1.1.0",
- "Microsoft.Extensions.Logging": "1.1.0",
- "Microsoft.Extensions.Logging.Console": "1.1.0",
- "Microsoft.Extensions.Logging.Debug": "1.1.0",
- "Swashbuckle": "6.0.0-beta902",
- "Winton.Extensions.Configuration.Consul": {
- "target": "project"
- }
- },
- "frameworks": {
- "netcoreapp1.1": {
- "imports": [
- "dnxcore50"
- ]
- }
- },
- "name": "Website",
- "publishOptions": {
- "include": [
- "appsettings.json",
- "web.config"
- ]
- },
- "runtimeOptions": {
- "configProperties": {
- "System.GC.Server": true
- }
- },
- "tooling": {
- "defaultNamespace": "Winton.Extensions.Configuration.Consul.Website"
- }
-}
\ No newline at end of file
diff --git a/test/Website/run.sh b/test/Website/run.sh
index de432a4..4cd28bc 100755
--- a/test/Website/run.sh
+++ b/test/Website/run.sh
@@ -1,4 +1,7 @@
-workDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-dotnet publish $workDir --configuration Release
-(cd $workDir && docker-compose rm -f)
-docker-compose -f $workDir/docker-compose.yml up --build --force-recreate
+#! /bin/bash
+
+pushd $( dirname $0 )
+dotnet publish --configuration Release
+docker-compose rm -f
+docker-compose -f docker-compose.yml up --build --force-recreate
+popd
diff --git a/test/Website/web.config b/test/Website/web.config
deleted file mode 100755
index bc89e9a..0000000
--- a/test/Website/web.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/test/Winton.Extensions.Configuration.Consul.Test/ConfigQueryResultTests.cs b/test/Winton.Extensions.Configuration.Consul.Test/ConfigQueryResultTests.cs
index 8189f1a..1c4c5da 100644
--- a/test/Winton.Extensions.Configuration.Consul.Test/ConfigQueryResultTests.cs
+++ b/test/Winton.Extensions.Configuration.Consul.Test/ConfigQueryResultTests.cs
@@ -18,7 +18,7 @@ public void ShouldSetExistsToFalseWhenConstructedFromNullResult()
[Test]
public void ShouldSetExistsToFalseWhenConstructedFromResultWithNullResponse()
{
- QueryResult kvPairResult = new QueryResult
+ var kvPairResult = new QueryResult
{
Response = null,
StatusCode = HttpStatusCode.OK
@@ -32,11 +32,11 @@ public void ShouldSetExistsToFalseWhenConstructedFromResultWithNullResponse()
[Test]
public void ShouldSetExistsToFalseWhenConstructedFromResultWithNullValue()
{
- QueryResult kvPairResult = new QueryResult
+ var kvPairResult = new QueryResult
{
Response = new KVPair("Key")
{
- Value = null
+ Value = null
},
StatusCode = HttpStatusCode.OK
};
@@ -49,11 +49,11 @@ public void ShouldSetExistsToFalseWhenConstructedFromResultWithNullValue()
[Test]
public void ShouldSetExistsToFalseWhenConstructedFromResultWithEmptyValue()
{
- QueryResult kvPairResult = new QueryResult
+ var kvPairResult = new QueryResult
{
Response = new KVPair("Key")
{
- Value = new byte[]{}
+ Value = new byte[] { }
},
StatusCode = HttpStatusCode.OK
};
@@ -66,7 +66,7 @@ public void ShouldSetExistsToFalseWhenConstructedFromResultWithEmptyValue()
[Test]
public void ShouldSetExistsToFalseWhenConstructedFromResultWithNotFoundStatus()
{
- QueryResult kvPairResult = new QueryResult
+ var kvPairResult = new QueryResult
{
StatusCode = HttpStatusCode.NotFound
};
@@ -79,8 +79,8 @@ public void ShouldSetExistsToFalseWhenConstructedFromResultWithNotFoundStatus()
[Test]
public void ShouldSetValueToResultValue()
{
- var actualValue = new byte[]{1};
- QueryResult kvPairResult = new QueryResult
+ var actualValue = new byte[] { 1 };
+ var kvPairResult = new QueryResult
{
Response = new KVPair("Key")
{
diff --git a/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationClientTests.cs b/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationClientTests.cs
index ffc7420..810cfac 100644
--- a/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationClientTests.cs
+++ b/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationClientTests.cs
@@ -109,7 +109,7 @@ public void ShouldUseLongPollingToPollForChangesWhenWatch()
public async Task ShouldUseLongPollingWithLatestIndexFromGetWhenWatch()
{
ulong lastWaitIndex = 0;
- ulong lastIndex = 1;
+ const ulong lastIndex = 1;
var completion = new TaskCompletionSource();
// Get config once which should update the latest index
@@ -126,7 +126,7 @@ public async Task ShouldUseLongPollingWithLatestIndexFromGetWhenWatch()
};
_kvMock
.Setup(kv => kv.Get(_Key, It.IsAny(), _cancellationToken))
- .Callback((string key, QueryOptions options, CancellationToken cancellationToken) =>
+ .Callback((string key, QueryOptions options, CancellationToken cancellationToken) =>
{
lastWaitIndex = options.WaitIndex;
})
@@ -145,7 +145,7 @@ public async Task ShouldUseLongPollingWithLatestIndexFromGetWhenWatch()
public async Task ShouldUseLongPollingWithWaitIndexFromPreviousWatchWhenWatch()
{
ulong lastWaitIndex = 0;
- ulong lastIndex = 1;
+ const ulong lastIndex = 1;
var completion = new TaskCompletionSource();
// Simulate the first change in config which generates a new index
@@ -158,7 +158,7 @@ public async Task ShouldUseLongPollingWithWaitIndexFromPreviousWatchWhenWatch()
};
_kvMock
.Setup(kv => kv.Get(_Key, It.IsAny(), _cancellationToken))
- .Callback((string key, QueryOptions options, CancellationToken cancellationToken) =>
+ .Callback((string key, QueryOptions options, CancellationToken cancellationToken) =>
{
lastWaitIndex = options.WaitIndex;
})
@@ -199,12 +199,12 @@ public async Task ShouldInvokeExceptionActionWhenWatchThrowsException()
Exception actualException = null;
Exception expectedException = new Exception();
var configChangedCompletion = new TaskCompletionSource();
-
+
_kvMock
.Setup(kv => kv.Get(_Key, It.IsAny(), _cancellationToken))
.ThrowsAsync(expectedException);
- _consulConfigurationClient.Watch(exceptionContext =>
+ _consulConfigurationClient.Watch(exceptionContext =>
{
actualException = exceptionContext.Exception;
_cancellationTokenSource.Cancel();
@@ -242,7 +242,7 @@ private async Task SimulateConfigChange(ulong lastIndex)
// Watch for changes
_consulConfigurationClient
.Watch(
- exceptionContext =>
+ exceptionContext =>
{
_cancellationTokenSource.Cancel();
configChangedCompletion.SetException(exceptionContext.Exception);
@@ -250,7 +250,7 @@ private async Task SimulateConfigChange(ulong lastIndex)
.RegisterChangeCallback(
o => configChangedCompletion.SetResult(true),
new object());
-
+
// Update mocked result to return a higher last index, which is what happens when changes occur
result.LastIndex = lastIndex;
_kvMock
diff --git a/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationProviderTests.cs b/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationProviderTests.cs
index 785a54f..4fac50c 100644
--- a/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationProviderTests.cs
+++ b/test/Winton.Extensions.Configuration.Consul.Test/ConsulConfigurationProviderTests.cs
@@ -13,7 +13,7 @@ namespace Winton.Extensions.Configuration.Consul
[TestOf(nameof(ConsulConfigurationProvider))]
internal sealed class ConsulConfigurationProviderTests
{
- const string _Key = "Test/Development";
+ private const string _Key = "Test/Development";
private ConsulConfigurationProvider _consulConfigProvider;
private Mock _consulConfigSourceMock;
@@ -55,7 +55,7 @@ public void ShouldThrowIfParserIsNullWhenConstructed()
_consulConfigSourceMock.SetupGet(ccs => ccs.Parser).Returns((IConfigurationParser)null);
Assert.That(
- () => new ConsulConfigurationProvider(_consulConfigSourceMock.Object, _consulConfigClientMock.Object),
+ () => new ConsulConfigurationProvider(_consulConfigSourceMock.Object, _consulConfigClientMock.Object),
Throws.TypeOf()
.And.Message.Contains(nameof(_consulConfigSourceMock.Object.Parser)));
}
@@ -66,12 +66,11 @@ public void ShouldThrowIfParserIsNullWhenConstructed()
public void ShouldParseLoadedConfigIntoDictionary(string actualKey, string lookupKey)
{
const string configValue = "Value";
- var parsedData = new Dictionary{{actualKey, configValue}};
+ var parsedData = new Dictionary { { actualKey, configValue } };
DoLoad(parsedData);
- string actualValue;
- _consulConfigProvider.TryGet(lookupKey, out actualValue);
+ _consulConfigProvider.TryGet(lookupKey, out string actualValue);
Assert.That(actualValue, Is.EqualTo(configValue));
}
@@ -80,7 +79,7 @@ public void ShouldHaveEmptyDataIfConfigDoesNotExistdAndIsOptional()
{
_consulConfigSourceMock.SetupGet(ccs => ccs.Optional).Returns(true);
_configQueryResultMock.Setup(cqr => cqr.Exists).Returns(false);
-
+
_consulConfigProvider.Load();
Assert.That(
@@ -93,7 +92,7 @@ public void ShouldNotParseIfConfigBytesIsNullWhenLoad()
{
_consulConfigSourceMock.SetupGet(ccs => ccs.Optional).Returns(true);
_configQueryResultMock.Setup(cqr => cqr.Exists).Returns(false);
-
+
_consulConfigProvider.Load();
Assert.That(
@@ -114,12 +113,14 @@ public void ShouldThrowIfConfigDoesNotExistAndIsNotOptonalWhenLoad()
{
actualExceptionContext = exceptionContext;
});
-
- try
+
+ try
{
_consulConfigProvider.Load();
}
- catch {}
+ catch
+ {
+ }
Assert.That(
actualExceptionContext.Exception.Message,
@@ -129,8 +130,8 @@ public void ShouldThrowIfConfigDoesNotExistAndIsNotOptonalWhenLoad()
[Test]
public void ShouldCallSourceOnLoadExceptionActionWhenExceptionDuringLoad()
{
- bool calledOnLoadException = false;
-
+ var calledOnLoadException = false;
+
_consulConfigClientMock.Setup(ccc => ccc.GetConfig()).ThrowsAsync(new Exception());
_consulConfigSourceMock
.SetupGet(ccs => ccs.OnLoadException)
@@ -138,12 +139,14 @@ public void ShouldCallSourceOnLoadExceptionActionWhenExceptionDuringLoad()
{
calledOnLoadException = true;
});
-
+
try
{
_consulConfigProvider.Load();
}
- catch {}
+ catch
+ {
+ }
Assert.That(calledOnLoadException, Is.True);
}
@@ -153,29 +156,31 @@ public void ShouldSetExceptionInLoadExceptionContextWhenExceptionDuringLoad()
{
ConsulLoadExceptionContext actualExceptionContext = null;
var expectedException = new Exception("Failed to load from Consul agent");
-
+
_consulConfigClientMock.Setup(ccc => ccc.GetConfig()).ThrowsAsync(expectedException);
_consulConfigSourceMock
.SetupGet(ccs => ccs.OnLoadException)
- .Returns(exceptionContext =>
+ .Returns(exceptionContext =>
{
actualExceptionContext = exceptionContext;
});
-
- try
+
+ try
{
_consulConfigProvider.Load();
}
- catch {}
+ catch
+ {
+ }
Assert.That(actualExceptionContext.Exception, Is.SameAs(expectedException));
}
- [Test]
+ [Test]
public void ShouldSetSourceInLoadExceptionContextWhenExceptionDuringLoad()
{
ConsulLoadExceptionContext actualExceptionContext = null;
-
+
_consulConfigClientMock.Setup(ccc => ccc.GetConfig()).ThrowsAsync(new Exception());
_consulConfigSourceMock
.SetupGet(ccs => ccs.OnLoadException)
@@ -183,12 +188,14 @@ public void ShouldSetSourceInLoadExceptionContextWhenExceptionDuringLoad()
{
actualExceptionContext = exceptionContext;
});
-
- try
+
+ try
{
_consulConfigProvider.Load();
}
- catch {}
+ catch
+ {
+ }
Assert.That(actualExceptionContext.Source, Is.SameAs(_consulConfigSourceMock.Object));
}
@@ -197,7 +204,7 @@ public void ShouldSetSourceInLoadExceptionContextWhenExceptionDuringLoad()
public void ShouldThrowExceptionIfOnLoadExceptionDoesNotSetIgnoreWhenExceptionDuringLoad()
{
var exception = new Exception("Failed to load from Consul agent");
-
+
_consulConfigClientMock.Setup(ccc => ccc.GetConfig()).ThrowsAsync(exception);
_consulConfigSourceMock
.SetupGet(ccs => ccs.OnLoadException)
@@ -213,7 +220,7 @@ public void ShouldThrowExceptionIfOnLoadExceptionDoesNotSetIgnoreWhenExceptionDu
public void ShouldNotThrowExceptionIfOnLoadExceptionDoesSetIgnoreWhenExceptionDuringLoad()
{
var exception = new Exception("Failed to load from Consul agent");
-
+
_consulConfigClientMock.Setup(ccc => ccc.GetConfig()).ThrowsAsync(exception);
_consulConfigSourceMock
.SetupGet(ccs => ccs.OnLoadException)
@@ -262,7 +269,7 @@ public void ShouldReloadConfigIfReloadOnChangesAndDataInConsulHasChanged()
Assert.That(() => _consulConfigClientMock.Verify(ccc => ccc.GetConfig()), Throws.Nothing);
}
-
+
[Test]
[TestCase(true, TestName="ShouldNotThrowIfDoesNotExistOnReloadWhenConfigOptional")]
[TestCase(false, TestName="ShouldNotThrowIfDoesNotExistOnReloadWhenConfigIsNotOptional")]
@@ -291,7 +298,7 @@ public void ShouldNotOverwriteNonOptionalConfigIfDoesNotExistOnReload()
{
const string key = "Key";
const string value = "Test";
- var originalData = new Dictionary{{key, value}};
+ var originalData = new Dictionary { { key, value } };
Action