Stub logging
This commit is contained in:
Родитель
044e2448a9
Коммит
8af3962a44
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Steeltoe.Initializr.WebApi.Server.Data;
|
||||
|
||||
namespace Steeltoe.Initializr.WebApi.Server
|
||||
|
@ -10,14 +11,17 @@ namespace Steeltoe.Initializr.WebApi.Server
|
|||
[Route("api/[controller]")]
|
||||
public class ConfigurationController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<ConfigurationController> _logger;
|
||||
private readonly IConfigurationRepository _configurationRepository;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ConfigurationController.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">logger factory</param>
|
||||
/// <param name="configurationRepository">configuration repository</param>
|
||||
public ConfigurationController(IConfigurationRepository configurationRepository)
|
||||
public ConfigurationController(ILoggerFactory loggerFactory, IConfigurationRepository configurationRepository)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<ConfigurationController>();
|
||||
_configurationRepository = configurationRepository;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Steeltoe.Initializr.WebApi.Server
|
||||
{
|
||||
|
@ -9,6 +10,18 @@ namespace Steeltoe.Initializr.WebApi.Server
|
|||
[Route("api/starter.zip")]
|
||||
public class ProjectGenerationController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<ProjectGenerationController> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ConfigurationController.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">logger factory</param>
|
||||
/// <param name="configurationRepository">configuration repository</param>
|
||||
public ProjectGenerationController(ILoggerFactory loggerFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<ProjectGenerationController>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements <code>GET</code>..
|
||||
/// </summary>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Steeltoe.Initializr.WebApi.Server.Models.Metadata;
|
||||
|
||||
namespace Steeltoe.Initializr.WebApi.Server.Data
|
||||
|
@ -9,12 +9,23 @@ namespace Steeltoe.Initializr.WebApi.Server.Data
|
|||
/// </summary>
|
||||
public class LocalConfigurationRepository : IConfigurationRepository
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the prohect configuration defined by the local JSON file.
|
||||
/// Create a new LocalConfigurationRepository.
|
||||
/// </summary>
|
||||
public LocalConfigurationRepository(ILoggerFactory loggerFactory)
|
||||
{
|
||||
_logger = loggerFactory?.CreateLogger<LocalConfigurationRepository>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the project configuration defined by the local JSON file.
|
||||
/// </summary>
|
||||
/// <returns>project generation configuration</returns>
|
||||
public Task<Configuration> GetConfiguration()
|
||||
{
|
||||
_logger?.LogInformation("getting configuration");
|
||||
var config = new Configuration();
|
||||
var result = new TaskCompletionSource<Configuration>();
|
||||
result.SetResult(config);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Steeltoe.Initializr.WebApi.Server.Data;
|
||||
|
@ -9,9 +8,9 @@ namespace Steeltoe.Initializr.WebApi.Server.Test.Data
|
|||
public class LocalConfigurationRepositoryTest
|
||||
{
|
||||
[Fact]
|
||||
public async Task EndpointExistsTest()
|
||||
public async Task LocalGetConfiguration()
|
||||
{
|
||||
var configRepo = new LocalConfigurationRepository();
|
||||
var configRepo = new LocalConfigurationRepository(null);
|
||||
var config = await configRepo.GetConfiguration();
|
||||
config.Should().NotBeNull();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="Moq" Version="4.14.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
|
Загрузка…
Ссылка в новой задаче