diff --git a/samples/Dressca/dressca-backend/Dressca.Web.Consumer.slnf b/samples/Dressca/dressca-backend/Dressca.Web.Consumer.slnf index 3ff774138..f0819332d 100644 --- a/samples/Dressca/dressca-backend/Dressca.Web.Consumer.slnf +++ b/samples/Dressca/dressca-backend/Dressca.Web.Consumer.slnf @@ -8,11 +8,13 @@ "src\\Dressca.SystemCommon\\Dressca.SystemCommon.csproj", "src\\Dressca.Web.Consumer.Dto\\Dressca.Web.Consumer.Dto.csproj", "src\\Dressca.Web.Consumer\\Dressca.Web.Consumer.csproj", + "src\\Dressca.Web\\Dressca.Web.csproj", "src\\Maris.Logging.Testing\\Maris.Logging.Testing.csproj", "tests\\Dressca.IntegrationTest\\Dressca.IntegrationTest.csproj", "tests\\Dressca.UnitTests.ApplicationCore\\Dressca.UnitTests.ApplicationCore.csproj", "tests\\Dressca.UnitTests.SystemCommon\\Dressca.UnitTests.SystemCommon.csproj", "tests\\Dressca.UnitTests.Web.Consumer\\Dressca.UnitTests.Web.Consumer.csproj", + "tests\\Dressca.UnitTests.Web\\Dressca.UnitTests.Web.csproj", "tests\\Maris.Logging.Testing.Tests\\Maris.Logging.Testing.Tests.csproj" ] } diff --git a/samples/Dressca/dressca-backend/Dressca.sln b/samples/Dressca/dressca-backend/Dressca.sln index 646646834..ea89d8be0 100644 --- a/samples/Dressca/dressca-backend/Dressca.sln +++ b/samples/Dressca/dressca-backend/Dressca.sln @@ -43,6 +43,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dressca.UnitTests.Web.Consu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dressca.Web.Consumer.Dto", "src\Dressca.Web.Consumer.Dto\Dressca.Web.Consumer.Dto.csproj", "{DF1A785A-FB0B-451E-B459-E65FDCB67845}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dressca.Web", "src\Dressca.Web\Dressca.Web.csproj", "{CB5845EF-7067-407D-97D9-CA4E5B6FBA70}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dressca.UnitTests.Web", "tests\Dressca.UnitTests.Web\Dressca.UnitTests.Web.csproj", "{688341DB-7DDD-4001-A418-89A1D7C8C20D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +101,14 @@ Global {DF1A785A-FB0B-451E-B459-E65FDCB67845}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF1A785A-FB0B-451E-B459-E65FDCB67845}.Release|Any CPU.ActiveCfg = Release|Any CPU {DF1A785A-FB0B-451E-B459-E65FDCB67845}.Release|Any CPU.Build.0 = Release|Any CPU + {CB5845EF-7067-407D-97D9-CA4E5B6FBA70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB5845EF-7067-407D-97D9-CA4E5B6FBA70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB5845EF-7067-407D-97D9-CA4E5B6FBA70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB5845EF-7067-407D-97D9-CA4E5B6FBA70}.Release|Any CPU.Build.0 = Release|Any CPU + {688341DB-7DDD-4001-A418-89A1D7C8C20D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {688341DB-7DDD-4001-A418-89A1D7C8C20D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {688341DB-7DDD-4001-A418-89A1D7C8C20D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {688341DB-7DDD-4001-A418-89A1D7C8C20D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -114,6 +126,8 @@ Global {D9A4BA02-8886-48C3-AD6E-EE8DA260DC8C} = {16A54A4D-8AEA-42B3-B8CF-D8C7650BB3C6} {7BA7B435-5790-4F8F-BA23-A9F87A86BB66} = {00E7327F-10DF-4937-AC61-FE2FCDCCA88B} {DF1A785A-FB0B-451E-B459-E65FDCB67845} = {16A54A4D-8AEA-42B3-B8CF-D8C7650BB3C6} + {CB5845EF-7067-407D-97D9-CA4E5B6FBA70} = {16A54A4D-8AEA-42B3-B8CF-D8C7650BB3C6} + {688341DB-7DDD-4001-A418-89A1D7C8C20D} = {00E7327F-10DF-4937-AC61-FE2FCDCCA88B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8FD66EC1-E1D1-4664-9ACE-8026659FD708} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Dressca.Web.Consumer.csproj b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Dressca.Web.Consumer.csproj index ea80bc373..c3a4f5dca 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Dressca.Web.Consumer.csproj +++ b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Dressca.Web.Consumer.csproj @@ -43,6 +43,7 @@ + diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Events.cs b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Events.cs index e5fbff78a..f7a2c541e 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Events.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Events.cs @@ -1,37 +1,32 @@ namespace Dressca.Web.Consumer; /// -/// イベントIDを管理するクラスです。 +/// イベント ID を管理するクラスです。 /// internal static class Events { /// - /// 業務例外が検出されたことを示すイベントID + /// クライアント側から不正な HTTP リクエストを受信したことを示すイベント ID です。 /// - internal static readonly EventId BusinessExceptionHandled = new(1001, nameof(BusinessExceptionHandled)); + internal static readonly EventId ReceiveHttpBadRequest = new(1001, nameof(ReceiveHttpBadRequest)); /// - /// クライアント側から不正なHTTPリクエストを受信したことを示すイベントID + /// アセットが見つからなかったことを示すイベント ID です。 /// - internal static readonly EventId ReceiveHttpBadRequest = new(1101, nameof(ReceiveHttpBadRequest)); + internal static readonly EventId AssetNotFound = new(1101, nameof(AssetNotFound)); /// - /// アセットが見つからなかったことを示すイベントID + /// 指定された商品が買い物かご内に存在しなかったことを示すイベント ID です。 /// - internal static readonly EventId AssetNotFound = new(1201, nameof(AssetNotFound)); + internal static readonly EventId CatalogItemIdDoesNotExistInBasket = new(1201, nameof(CatalogItemIdDoesNotExistInBasket)); /// - /// 指定された商品が買い物かご内に存在しなかったことを示すイベントID + /// 注文情報が見つからなかったことを示すイベント ID です。 /// - internal static readonly EventId CatalogItemIdDoesNotExistInBasket = new(1301, nameof(CatalogItemIdDoesNotExistInBasket)); + internal static readonly EventId OrderNotFound = new(1301, nameof(OrderNotFound)); /// - /// 注文情報が見つからなかったことを示すイベントID - /// - internal static readonly EventId OrderNotFound = new(1401, nameof(OrderNotFound)); - - /// - /// デバッグ用のイベントID + /// デバッグ用のイベント ID です。 /// internal static readonly EventId DebugEvent = new(9999, nameof(DebugEvent)); } diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Program.cs b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Program.cs index abbefe5b0..d7055ed98 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Program.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Program.cs @@ -6,11 +6,11 @@ using Dressca.Web.Consumer; using Dressca.Web.Consumer.Baskets; using Dressca.Web.Consumer.Configuration; -using Dressca.Web.Consumer.Controllers; using Dressca.Web.Consumer.HealthChecks; using Dressca.Web.Consumer.Mapper; using Dressca.Web.Consumer.Resources; -using Dressca.Web.Consumer.Runtime; +using Dressca.Web.Controllers; +using Dressca.Web.Runtime; using Microsoft.AspNetCore.HttpLogging; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.Extensions.DependencyInjection.Extensions; diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.Designer.cs b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.Designer.cs index 74dccff54..aba07110e 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.Designer.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.Designer.cs @@ -60,15 +60,6 @@ internal Messages() { } } - /// - /// 業務エラーが発生しました。 に類似しているローカライズされた文字列を検索します。 - /// - internal static string BusinessExceptionHandled { - get { - return ResourceManager.GetString("BusinessExceptionHandled", resourceCulture); - } - } - /// /// アセットタイプ: {0} を Content-Type に変換できません。 に類似しているローカライズされた文字列を検索します。 /// diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.resx b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.resx index f763529c0..26cb2fe40 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.resx +++ b/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Resources/Messages.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 業務エラーが発生しました。 - アセットタイプ: {0} を Content-Type に変換できません。 diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Controllers/ErrorController.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/ErrorController.cs similarity index 64% rename from samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Controllers/ErrorController.cs rename to samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/ErrorController.cs index c000d0416..4f1943053 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Controllers/ErrorController.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Controllers/ErrorController.cs @@ -1,7 +1,8 @@ using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; -namespace Dressca.Web.Consumer.Controllers; +namespace Dressca.Web.Controllers; /// /// エラーの情報にアクセスする API コントローラーです。 @@ -12,21 +13,31 @@ namespace Dressca.Web.Consumer.Controllers; public class ErrorController : ControllerBase { /// - /// 開発環境におけるエラー情報取得のためのルートパス ( /error-development ) 。 + /// 開発環境におけるエラー情報取得のためのルートパスのリテラル値 ( /error-development ) です。 /// - internal const string DevelopmentErrorRoute = "/error-development"; + private const string DevelopMentErrorRouteLiteral = "/error-development"; /// - /// 実行環境におけるエラー情報取得のためのルートパス ( /error ) 。 + /// 実行環境におけるエラー情報取得のためのルートパスのリテラル値 ( /error ) です。 /// - internal const string ErrorRoute = "/error"; + private const string ErrorRouteLiteral = "/error"; + + /// + /// 開発環境におけるエラー情報取得のためのルートパス( /error-development )を取得します。 + /// + public static string DevelopmentErrorRoute => DevelopMentErrorRouteLiteral; + + /// + /// 実行環境におけるエラー情報取得のためのルートパス ( /error )を取得します。 + /// + public static string ErrorRoute => ErrorRouteLiteral; /// /// 開発環境でのエラーレスポンスを取得します。 /// /// 環境の情報。 /// エラーの詳細情報。 - [Route(DevelopmentErrorRoute)] + [Route(DevelopMentErrorRouteLiteral)] public IActionResult HandleErrorDevelopment([FromServices] IHostEnvironment hostEnvironment) { if (!hostEnvironment.IsDevelopment()) @@ -44,6 +55,6 @@ public IActionResult HandleErrorDevelopment([FromServices] IHostEnvironment host /// 実行環境でのエラーレスポンスを取得します。 /// /// エラーの情報。 - [Route(ErrorRoute)] + [Route(ErrorRouteLiteral)] public IActionResult HandleError() => this.Problem(); } diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj b/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj new file mode 100644 index 000000000..ab390b71b --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Dressca.Web.csproj @@ -0,0 +1,37 @@ + + + + Resources + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + True + True + Messages.resx + + + + + + ResXFileCodeGenerator + Messages.Designer.cs + + + + diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Events.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Events.cs new file mode 100644 index 000000000..f336f59a9 --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Events.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.Logging; + +namespace Dressca.Web; + +/// +/// イベント ID を管理するクラスです。 +/// +internal static class Events +{ + /// + /// 業務例外が検出されたことを示すイベント ID です。 + /// + internal static readonly EventId BusinessExceptionHandled = new(0001, nameof(BusinessExceptionHandled)); +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Resources/Messages.Designer.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Resources/Messages.Designer.cs new file mode 100644 index 000000000..4041cd22a --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Resources/Messages.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// このコードはツールによって生成されました。 +// ランタイム バージョン:4.0.30319.42000 +// +// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 +// コードが再生成されるときに損失したりします。 +// +//------------------------------------------------------------------------------ + +namespace Dressca.Web.Resources { + using System; + + + /// + /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 + /// + // このクラスは StronglyTypedResourceBuilder クラスが ResGen + // または Visual Studio のようなツールを使用して自動生成されました。 + // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に + // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Messages { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Messages() { + } + + /// + /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dressca.Web.Resources.Messages", typeof(Messages).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします + /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 業務エラーが発生しました。 に類似しているローカライズされた文字列を検索します。 + /// + internal static string BusinessExceptionHandled { + get { + return ResourceManager.GetString("BusinessExceptionHandled", resourceCulture); + } + } + } +} diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web/Resources/Messages.resx b/samples/Dressca/dressca-backend/src/Dressca.Web/Resources/Messages.resx new file mode 100644 index 000000000..b58b7759d --- /dev/null +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Resources/Messages.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 業務エラーが発生しました。 + + \ No newline at end of file diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionDevelopmentFilter.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionDevelopmentFilter.cs similarity index 95% rename from samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionDevelopmentFilter.cs rename to samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionDevelopmentFilter.cs index 06214a170..eaab2017f 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionDevelopmentFilter.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionDevelopmentFilter.cs @@ -1,11 +1,12 @@ using System.Net; using Dressca.SystemCommon; -using Dressca.Web.Consumer.Resources; +using Dressca.Web.Resources; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.Extensions.Logging; -namespace Dressca.Web.Consumer.Runtime; +namespace Dressca.Web.Runtime; /// /// を HTTP 400 のレスポンスに変換する diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionFilter.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionFilter.cs similarity index 95% rename from samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionFilter.cs rename to samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionFilter.cs index f76ba50ef..d3969538b 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionFilter.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionFilter.cs @@ -1,11 +1,12 @@ using System.Net; using Dressca.SystemCommon; -using Dressca.Web.Consumer.Resources; +using Dressca.Web.Resources; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.Extensions.Logging; -namespace Dressca.Web.Consumer.Runtime; +namespace Dressca.Web.Runtime; /// /// を HTTP 400 のレスポンスに変換する diff --git a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionFilterBase.cs b/samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionFilterBase.cs similarity index 95% rename from samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionFilterBase.cs rename to samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionFilterBase.cs index c50011300..c96a23c2c 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.Web.Consumer/Runtime/BusinessExceptionFilterBase.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.Web/Runtime/BusinessExceptionFilterBase.cs @@ -1,9 +1,10 @@ using Dressca.SystemCommon; -using Dressca.Web.Consumer.Resources; +using Dressca.Web.Resources; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Logging; -namespace Dressca.Web.Consumer.Runtime; +namespace Dressca.Web.Runtime; /// /// を HTTP 400 のレスポンスに変換する diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Dressca.UnitTests.Web.csproj b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Dressca.UnitTests.Web.csproj new file mode 100644 index 000000000..c45115625 --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Dressca.UnitTests.Web.csproj @@ -0,0 +1,35 @@ + + + + false + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web.Consumer/Runtime/BusinessExceptionDevelopmentFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs similarity index 96% rename from samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web.Consumer/Runtime/BusinessExceptionDevelopmentFilterTest.cs rename to samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs index ad3f18795..f34399aed 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web.Consumer/Runtime/BusinessExceptionDevelopmentFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs @@ -1,6 +1,5 @@ using Dressca.SystemCommon; -using Dressca.UnitTests.Web.Consumer; -using Dressca.Web.Consumer.Runtime; +using Dressca.Web.Runtime; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; @@ -11,7 +10,7 @@ using Microsoft.Extensions.Logging; using Xunit.Abstractions; -namespace Dressca.UnitTests.Web.Consumer.Runtime; +namespace Dressca.UnitTests.Web.Runtime; public class BusinessExceptionDevelopmentFilterTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { @@ -78,7 +77,7 @@ public void OnException_情報ログが1件登録される() var record = this.LogCollector.LatestRecord; Assert.Equal("業務エラーが発生しました。", record.Message); Assert.Equal(LogLevel.Information, record.Level); - Assert.Equal(1001, record.Id); + Assert.Equal(0001, record.Id); Assert.Same(context.Exception, record.Exception); } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web.Consumer/Runtime/BusinessExceptionFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Runtime/BusinessExceptionFilterTest.cs similarity index 97% rename from samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web.Consumer/Runtime/BusinessExceptionFilterTest.cs rename to samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Runtime/BusinessExceptionFilterTest.cs index ae742ada3..d70c54715 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web.Consumer/Runtime/BusinessExceptionFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/Runtime/BusinessExceptionFilterTest.cs @@ -1,5 +1,5 @@ using Dressca.SystemCommon; -using Dressca.Web.Consumer.Runtime; +using Dressca.Web.Runtime; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; @@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging; using Xunit.Abstractions; -namespace Dressca.UnitTests.Web.Consumer.Runtime; +namespace Dressca.UnitTests.Web.Runtime; public class BusinessExceptionFilterTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { @@ -77,7 +77,7 @@ public void OnException_情報ログが1件登録される() var record = this.LogCollector.LatestRecord; Assert.Equal("業務エラーが発生しました。", record.Message); Assert.Equal(LogLevel.Information, record.Level); - Assert.Equal(1001, record.Id); + Assert.Equal(0001, record.Id); Assert.Same(context.Exception, record.Exception); } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/TestBase.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/TestBase.cs new file mode 100644 index 000000000..3b2dc463d --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests.Web/TestBase.cs @@ -0,0 +1,28 @@ +using Maris.Logging.Testing.Xunit; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Testing; +using Xunit.Abstractions; + +namespace Dressca.UnitTests.Web; + +public class TestBase +{ + private readonly TestLoggerManager loggerManager; + + protected TestBase(ITestOutputHelper testOutputHelper) + { + ArgumentNullException.ThrowIfNull(testOutputHelper); + this.loggerManager = new TestLoggerManager(testOutputHelper); + } + + protected FakeLogCollector LogCollector => this.loggerManager.LogCollector; + + protected ILogger CreateTestLogger() + => this.loggerManager.CreateLogger(); + + protected ILogger CreateTestLogger(Type type) + => this.loggerManager.CreateLogger(type); + + protected ILogger CreateTestLogger(string categoryName) + => this.loggerManager.CreateLogger(categoryName); +}