Compare commits

...

2 Commits

Author SHA1 Message Date
042f633603 간단한 API 테스트 2025-10-15 02:27:39 +09:00
6142899fed 테스트 프로젝트 추가 2025-10-15 02:27:29 +09:00
7 changed files with 126 additions and 5 deletions

View File

@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundConsole", "Warhound
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundLib", "WarhoundLib\WarhoundLib.csproj", "{7E3472E9-86E9-4032-826C-0DA805C2EBCE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundLib", "WarhoundLib\WarhoundLib.csproj", "{7E3472E9-86E9-4032-826C-0DA805C2EBCE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarhoundTest", "WarhoundTest\WarhoundTest.csproj", "{D22BEA2A-08E9-498A-A087-FEFB8FA2AD08}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{7E3472E9-86E9-4032-826C-0DA805C2EBCE}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -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
View 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" });
}
}
}

View File

@@ -8,7 +8,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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> </ItemGroup>
</Project> </Project>

View File

@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]

11
WarhoundTest/Test1.cs Normal file
View File

@@ -0,0 +1,11 @@
namespace WarhoundTest
{
[TestClass]
public sealed class Test1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

View 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>