Skip to content

Commit 48a43c2

Browse files
restructure some tests and other files
1 parent 39cb2a5 commit 48a43c2

File tree

17 files changed

+392
-23
lines changed

17 files changed

+392
-23
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,6 @@ $RECYCLE.BIN/
431431
!.vscode/tasks.json
432432
!.vscode/launch.json
433433
!.vscode/extensions.json
434+
435+
testapp/bin/*
436+
testapp/obj/*

src/Microstack.CLI/Program.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,25 @@
1717

1818
namespace Microstack.CLI
1919
{
20-
class Program
20+
public class Program
2121
{
22-
static void Main(string[] args)
22+
public static void Main(string[] args)
2323
{
2424
var cts = new CancellationTokenSource();
25+
CreateHostBuilder(args)
26+
.RunCommandLineApplicationAsync<MicroStack>(args, cts.Token)
27+
.GetAwaiter()
28+
.GetResult();
29+
}
30+
31+
public static IHostBuilder CreateHostBuilder(string[] args) =>
2532
Host.CreateDefaultBuilder(args)
26-
.ConfigureServices((context, services) => {
33+
.ConfigureServices((context, services) =>
34+
{
2735
services.AddLogging();
2836
services.AddSingleton<StackProcessor>();
29-
services.RegisterHandlers(sh => {
37+
services.RegisterHandlers(sh =>
38+
{
3039
sh.AddHandler<GitHandler>();
3140
sh.AddHandler<DotnetHandler>();
3241
});
@@ -37,10 +46,6 @@ static void Main(string[] args)
3746
services.AddSingleton<ProcessQueueTask>();
3847
services.AddHostedService(sp => sp.GetRequiredService<ProcessQueueTask>());
3948
services.AddTransient<ConsoleHelper>();
40-
})
41-
.RunCommandLineApplicationAsync<MicroStack>(args, cts.Token)
42-
.GetAwaiter()
43-
.GetResult();
44-
}
49+
});
4550
}
4651
}

src/Microstack.sln

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microstack.Tests", "..\test
1919
EndProject
2020
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microstack.Common", "Microstack.Common\Microstack.Common.csproj", "{A8957924-FCB4-46A5-8489-39F878CD032A}"
2121
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testapp", "testapp", "{18E368A5-9AA6-437E-A60D-3AD94A758D3D}"
23+
EndProject
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "testapp", "..\testapp\testapp.csproj", "{767EFD95-3C18-45A4-83D5-C35B2603D68F}"
25+
EndProject
2226
Global
2327
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2428
Debug|Any CPU = Debug|Any CPU
@@ -125,10 +129,25 @@ Global
125129
{A8957924-FCB4-46A5-8489-39F878CD032A}.Release|x64.Build.0 = Release|Any CPU
126130
{A8957924-FCB4-46A5-8489-39F878CD032A}.Release|x86.ActiveCfg = Release|Any CPU
127131
{A8957924-FCB4-46A5-8489-39F878CD032A}.Release|x86.Build.0 = Release|Any CPU
132+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
133+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Debug|Any CPU.Build.0 = Debug|Any CPU
134+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Debug|x64.ActiveCfg = Debug|Any CPU
135+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Debug|x64.Build.0 = Debug|Any CPU
136+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Debug|x86.ActiveCfg = Debug|Any CPU
137+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Debug|x86.Build.0 = Debug|Any CPU
138+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Release|Any CPU.ActiveCfg = Release|Any CPU
139+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Release|Any CPU.Build.0 = Release|Any CPU
140+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Release|x64.ActiveCfg = Release|Any CPU
141+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Release|x64.Build.0 = Release|Any CPU
142+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Release|x86.ActiveCfg = Release|Any CPU
143+
{767EFD95-3C18-45A4-83D5-C35B2603D68F}.Release|x86.Build.0 = Release|Any CPU
128144
EndGlobalSection
129145
GlobalSection(SolutionProperties) = preSolution
130146
HideSolutionNode = FALSE
131147
EndGlobalSection
148+
GlobalSection(NestedProjects) = preSolution
149+
{767EFD95-3C18-45A4-83D5-C35B2603D68F} = {18E368A5-9AA6-437E-A60D-3AD94A758D3D}
150+
EndGlobalSection
132151
GlobalSection(ExtensibilityGlobals) = postSolution
133152
SolutionGuid = {663FCCAA-E838-4798-8562-4E931383599B}
134153
EndGlobalSection

testapp/.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/testapp.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}",
16+
"stopAtEntry": false,
17+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
18+
"serverReadyAction": {
19+
"action": "openExternally",
20+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
21+
},
22+
"env": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"sourceFileMap": {
26+
"/Views": "${workspaceFolder}/Views"
27+
}
28+
},
29+
{
30+
"name": ".NET Core Attach",
31+
"type": "coreclr",
32+
"request": "attach",
33+
"processId": "${command:pickProcess}"
34+
}
35+
]
36+
}

testapp/.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/testapp.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/testapp.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/testapp.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Logging;
8+
9+
namespace testapp.Controllers
10+
{
11+
[ApiController]
12+
[Route("[controller]")]
13+
public class AppSettingsController : ControllerBase
14+
{
15+
private static readonly string[] Summaries = new[]
16+
{
17+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
18+
};
19+
private readonly IConfiguration configuration;
20+
21+
public AppSettingsController(IConfiguration configuration)
22+
{
23+
this.configuration = configuration;
24+
}
25+
26+
[HttpGet]
27+
[ProducesResponseType(typeof(IEnumerable<WeatherForecast>), 200)]
28+
public IEnumerable<WeatherForecast> Get()
29+
{
30+
var rng = new Random();
31+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
32+
{
33+
Date = DateTime.Now.AddDays(index),
34+
TemperatureC = rng.Next(-20, 55),
35+
Summary = Summaries[rng.Next(Summaries.Length)]
36+
})
37+
.ToArray();
38+
}
39+
40+
[HttpGet("{id}")]
41+
[ProducesResponseType(typeof(IEnumerable<string>), 200)]
42+
public IActionResult Get(string id)
43+
{
44+
return Ok(this.configuration[id]);
45+
}
46+
}
47+
}

testapp/Program.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace testapp
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
25+
}
26+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:17440",
8+
"sslPort": 44388
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"launchUrl": "weatherforecast",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"testapp": {
21+
"commandName": "Project",
22+
"launchBrowser": true,
23+
"launchUrl": "weatherforecast",
24+
"applicationUrl": "https://localhost:5002;http://localhost:5003",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
}
29+
}
30+
}

testapp/Startup.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.AspNetCore.HttpsPolicy;
8+
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.Extensions.Configuration;
10+
using Microsoft.Extensions.DependencyInjection;
11+
using Microsoft.Extensions.Hosting;
12+
using Microsoft.Extensions.Logging;
13+
14+
15+
namespace testapp
16+
{
17+
public class Startup
18+
{
19+
public Startup(IConfiguration configuration)
20+
{
21+
Configuration = configuration;
22+
}
23+
24+
public IConfiguration Configuration { get; }
25+
26+
// This method gets called by the runtime. Use this method to add services to the container.
27+
public void ConfigureServices(IServiceCollection services)
28+
{
29+
services.AddControllers();
30+
services.AddLogging();
31+
var builder = services.BuildServiceProvider();
32+
var logger = builder.GetRequiredService<ILogger<Startup>>();
33+
logger.LogInformation(Configuration["ComplexObj:ComplexKey"]);
34+
services.AddSwaggerGen();
35+
}
36+
37+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
39+
{
40+
app.UseSwagger();
41+
app.UseSwaggerUI(c => {
42+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
43+
});
44+
45+
if (env.IsDevelopment())
46+
{
47+
app.UseDeveloperExceptionPage();
48+
}
49+
50+
app.UseHttpsRedirection();
51+
52+
app.UseRouting();
53+
54+
app.UseAuthorization();
55+
56+
app.UseEndpoints(endpoints =>
57+
{
58+
endpoints.MapControllers();
59+
});
60+
}
61+
}
62+
}

testapp/WeatherForecast.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace testapp
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}

testapp/appsettings.Development.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}

testapp/appsettings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*",
10+
"Test": "Value",
11+
"ComplexObj": {
12+
"ComplexKey": "ComplexValue"
13+
}
14+
}

testapp/testapp.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.0" />
9+
</ItemGroup>
10+
11+
12+
</Project>

0 commit comments

Comments
 (0)