Compare commits
2 Commits
56334d6a64
...
042f633603
| Author | SHA1 | Date | |
|---|---|---|---|
| 042f633603 | |||
| 6142899fed |
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundConsole", "Warhound
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundLib", "WarhoundLib\WarhoundLib.csproj", "{7E3472E9-86E9-4032-826C-0DA805C2EBCE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundTest", "WarhoundTest\WarhoundTest.csproj", "{D22BEA2A-08E9-498A-A087-FEFB8FA2AD08}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{7E3472E9-86E9-4032-826C-0DA805C2EBCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7E3472E9-86E9-4032-826C-0DA805C2EBCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7E3472E9-86E9-4032-826C-0DA805C2EBCE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D22BEA2A-08E9-498A-A087-FEFB8FA2AD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D22BEA2A-08E9-498A-A087-FEFB8FA2AD08}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D22BEA2A-08E9-498A-A087-FEFB8FA2AD08}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D22BEA2A-08E9-498A-A087-FEFB8FA2AD08}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,10 +1,52 @@
|
||||
namespace WarhoundConsole
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace WarhoundConsole
|
||||
{
|
||||
internal class Program
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
try
|
||||
{
|
||||
MainInternal(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void MainInternal(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseUrls("http://localhost:80");
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.MapControllers();
|
||||
app.UseExceptionHandler(ExceptionHandler);
|
||||
app.Run();
|
||||
}
|
||||
|
||||
private static void ExceptionHandler(IApplicationBuilder applicationBuilder)
|
||||
{
|
||||
applicationBuilder.Run(async context =>
|
||||
{
|
||||
var exceptionHandlerFeature = context.Features.Get<IExceptionHandlerFeature>();
|
||||
if (exceptionHandlerFeature != null)
|
||||
{
|
||||
var exception = exceptionHandlerFeature.Error;
|
||||
|
||||
// Do something here
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
WarhoundConsole/Test.cs
Normal file
40
WarhoundConsole/Test.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WarhoundConsole
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/test")]
|
||||
public class Test : ControllerBase
|
||||
{
|
||||
[HttpGet("hello")]
|
||||
public ActionResult<string> GetGreeting()
|
||||
{
|
||||
string message = "Hello!!!";
|
||||
if (message.Length != 0)
|
||||
{
|
||||
//throw new Exception("Hello");
|
||||
}
|
||||
return Ok(message);
|
||||
}
|
||||
|
||||
[HttpGet("data")]
|
||||
public ActionResult<object> GetData()
|
||||
{
|
||||
var data = new { Id = 1, Name = "Sample Data", Timestamp = DateTime.UtcNow };
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
[HttpPost("json")]
|
||||
public ActionResult<object> asd([FromBody] object obj)
|
||||
{
|
||||
//if (obj == null)
|
||||
//{
|
||||
// return BadRequest("Invalid data.");
|
||||
//}
|
||||
|
||||
Console.Write(obj.ToString());
|
||||
|
||||
return Ok(new { a = 1, b = 2, c = "c" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WarhoundLib\WarhoundLib.csproj" />
|
||||
<ProjectReference Include="..\WarhoundLib\WarhoundLib.csproj" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
1
WarhoundTest/MSTestSettings.cs
Normal file
1
WarhoundTest/MSTestSettings.cs
Normal file
@@ -0,0 +1 @@
|
||||
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
|
||||
11
WarhoundTest/Test1.cs
Normal file
11
WarhoundTest/Test1.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace WarhoundTest
|
||||
{
|
||||
[TestClass]
|
||||
public sealed class Test1
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestMethod1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
19
WarhoundTest/WarhoundTest.csproj
Normal file
19
WarhoundTest/WarhoundTest.csproj
Normal file
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="MSTest.Sdk/3.6.4">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<!--
|
||||
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
|
||||
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
|
||||
-->
|
||||
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WarhoundLib\WarhoundLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user