Add some unit tests verifying Logging
This commit is contained in:
Родитель
208f3e8b23
Коммит
50704f7560
|
@ -47,27 +47,27 @@ namespace Spring.Extensions.Configuration.Server
|
|||
/// The environment used when accessing configuration data (defaults: Development)
|
||||
/// </summary>
|
||||
public string Environment { get; set; } = "Development";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The application name used when accessing configuration data (defaults: tbd)
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The label used when accessing configuration data (defaults: null)
|
||||
/// </summary>
|
||||
public string Label { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The username used when accessing the Config Server (defaults: null)
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The password used when accessing the Config Server (defaults: null)
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enables/Disables failfast behavior (defaults: false)
|
||||
/// </summary>
|
||||
|
@ -83,6 +83,14 @@ namespace Spring.Extensions.Configuration.Server
|
|||
_logger = logFactory?.CreateLogger<ConfigServerClientSettings>();
|
||||
}
|
||||
|
||||
internal ILogger Logger
|
||||
{
|
||||
get
|
||||
{
|
||||
return _logger;
|
||||
}
|
||||
}
|
||||
|
||||
internal ConfigServerClientSettings(IEnumerable<IConfigurationProvider> providers, ILoggerFactory logFactory = null)
|
||||
{
|
||||
|
||||
|
|
|
@ -137,6 +137,14 @@ namespace Spring.Extensions.Configuration.Server
|
|||
}
|
||||
}
|
||||
|
||||
internal ILogger Logger
|
||||
{
|
||||
get
|
||||
{
|
||||
return _logger;
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<Environment> RemoteLoadAsync(string path)
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc1-final",
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc1-final",
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"System.Net.Http": "4.0.0"
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Xunit;
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Spring.Extensions.Configuration.Server.Test
|
||||
{
|
||||
|
@ -54,6 +55,30 @@ namespace Spring.Extensions.Configuration.Server.Test
|
|||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddConfigService_WithLoggerFactorySucceeds()
|
||||
{
|
||||
// Arrange
|
||||
var configurationBuilder = new ConfigurationBuilder();
|
||||
var loggerFactory = new LoggerFactory();
|
||||
|
||||
// Act and Assert
|
||||
configurationBuilder.AddConfigServer(loggerFactory);
|
||||
|
||||
ConfigServerConfigurationProvider configServerProvider = null;
|
||||
foreach (IConfigurationProvider provider in configurationBuilder.Providers)
|
||||
{
|
||||
configServerProvider = provider as ConfigServerConfigurationProvider;
|
||||
if (configServerProvider != null)
|
||||
break;
|
||||
}
|
||||
|
||||
Assert.NotNull(configServerProvider);
|
||||
Assert.NotNull(configServerProvider.Logger);
|
||||
Assert.NotNull(configServerProvider.Settings.Logger);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddConfigService_JsonAppSettingsConfiguresClient()
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ using System.Collections.Generic;
|
|||
using System.Net.Http;
|
||||
using Xunit;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Spring.Extensions.Configuration.Server.Test
|
||||
{
|
||||
|
@ -50,6 +51,19 @@ namespace Spring.Extensions.Configuration.Server.Test
|
|||
Assert.Contains(nameof(httpClient), ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SettingsConstructor__WithLoggerFactorySucceeds()
|
||||
{
|
||||
// Arrange
|
||||
LoggerFactory logFactory = new LoggerFactory();
|
||||
ConfigServerClientSettings settings = new ConfigServerClientSettings(logFactory);
|
||||
|
||||
// Act and Assert
|
||||
var provider = new ConfigServerConfigurationProvider(settings, logFactory);
|
||||
Assert.NotNull(provider.Logger);
|
||||
Assert.NotNull(settings.Logger);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProvidersConstructor_InitializedWithDefaultsWhenNull()
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
|
||||
"Microsoft.Extensions.Configuration.Xml": "1.0.0-rc1-final",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
|
||||
"Spring.Extensions.Configuration.Server": "1.0.0-*",
|
||||
"xunit": "2.1.0",
|
||||
"xunit.runner.dnx": "2.1.0-rc1-build204"
|
||||
|
|
Загрузка…
Ссылка в новой задаче