|
2 | 2 | using Microsoft.Extensions.DependencyInjection; |
3 | 3 | using Microsoft.Extensions.Logging; |
4 | 4 | using System; |
| 5 | +using System.Collections.Generic; |
5 | 6 | using System.IO; |
| 7 | +using System.Linq; |
6 | 8 | using System.Threading.Tasks; |
7 | 9 | using Xunit.Abstractions; |
8 | 10 | using Xunit.Microsoft.DependencyInjection.Logging; |
@@ -49,24 +51,32 @@ public T GetService<T>(ITestOutputHelper testOutputHelper) |
49 | 51 | protected abstract string GetConfigurationFile(); |
50 | 52 | protected abstract void AddServices(IServiceCollection services, IConfiguration configuration); |
51 | 53 |
|
| 54 | + protected virtual IEnumerable<string> GetConfigurationFiles() |
| 55 | + { |
| 56 | + yield return GetConfigurationFile(); |
| 57 | + } |
| 58 | + |
52 | 59 | protected virtual ILoggingBuilder AddLoggingProvider(ILoggingBuilder loggingBuilder, ILoggerProvider loggerProvider) |
53 | 60 | => loggingBuilder.AddProvider(loggerProvider); |
54 | 61 |
|
55 | 62 | private IConfigurationRoot GetConfigurationRoot() |
56 | 63 | { |
57 | | - var configurationFile = GetConfigurationFile(); |
58 | | - |
| 64 | + var configurationFiles = GetConfigurationFiles(); |
59 | 65 | return |
60 | | - !string.IsNullOrEmpty(configurationFile) |
61 | | - ? GetConfigurationRoot(configurationFile) |
| 66 | + configurationFiles.All(c => !string.IsNullOrEmpty(c)) |
| 67 | + ? GetConfigurationRoot(configurationFiles) |
62 | 68 | : default; |
63 | 69 | } |
64 | 70 |
|
65 | | - private IConfigurationRoot GetConfigurationRoot(string configurationFile) => |
66 | | - new ConfigurationBuilder() |
67 | | - .SetBasePath(Directory.GetCurrentDirectory()) |
68 | | - .AddJsonFile(configurationFile) |
69 | | - .Build(); |
| 71 | + private IConfigurationRoot GetConfigurationRoot(IEnumerable<string> configurationFiles) |
| 72 | + { |
| 73 | + var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()); |
| 74 | + foreach(var configurationFile in configurationFiles) |
| 75 | + { |
| 76 | + builder.AddJsonFile(configurationFile); |
| 77 | + } |
| 78 | + return builder.Build(); |
| 79 | + } |
70 | 80 |
|
71 | 81 | protected virtual void Dispose(bool disposing) |
72 | 82 | { |
|
0 commit comments