From 68cdcf0237b2498e1623a8b08b9d3f4d7076c2c8 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:08:14 +0900 Subject: [PATCH 01/40] =?UTF-8?q?=E5=8D=98=E4=BD=93=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88?= =?UTF-8?q?=E3=81=ABLogger=E3=82=92=E4=BD=BF=E3=81=86=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE=E3=83=99=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/Dressca.UnitTests/TestBase.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 samples/Dressca/dressca-backend/tests/Dressca.UnitTests/TestBase.cs diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/TestBase.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/TestBase.cs new file mode 100644 index 000000000..0ee02a152 --- /dev/null +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/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; + +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); +} From 0789cc12055ca2144efc7435b61c3fba1af4fb8c Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:09:50 +0900 Subject: [PATCH 02/40] =?UTF-8?q?Dressca.UnitTests=E3=81=AELogger=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=86=E3=83=86=E3=82=B9=E3=83=88=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=81=A7TestBase=E3=82=92=E7=B6=99=E6=89=BF=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/AssetApplicationServiceTest.cs | 15 +++--- .../Baskets/BasketApplicationServiceTest.cs | 47 +++++++++---------- .../Catalog/CatalogApplicationServiceTest.cs | 17 ++++--- .../Catalog/CatalogDomainServiceTest.cs | 15 +++--- .../Ordering/OrderApplicationServiceTest.cs | 21 ++++----- .../BusinessExceptionDevelopmentFilterTest.cs | 11 ++--- .../Runtime/BusinessExceptionFilterTest.cs | 10 ++-- 7 files changed, 65 insertions(+), 71 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs index 943edbfff..e6efafbf4 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs @@ -1,15 +1,14 @@ using Dressca.ApplicationCore.Assets; -using Maris.Logging.Testing.Xunit; using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Assets; -public class AssetApplicationServiceTest +public class AssetApplicationServiceTest : TestBase { - private readonly TestLoggerManager loggerManager; - public AssetApplicationServiceTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } [Fact] public void GetAssetStreamInfo_リポジトリに指定したアセットコードの情報が見つからない場合は例外() @@ -21,7 +20,7 @@ public void GetAssetStreamInfo_リポジトリに指定したアセットコー .Setup(r => r.Find(assetCode)) .Returns((Asset?)null); var store = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new AssetApplicationService(repositoryMock.Object, store, logger); // Act @@ -46,7 +45,7 @@ public void GetAssetStreamInfo_ストアに指定したアセットコードの storeMock .Setup(s => s.GetStream(asset)) .Returns((Stream?)null); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new AssetApplicationService(repositoryMock.Object, storeMock.Object, logger); // Act @@ -72,7 +71,7 @@ public void GetAssetStreamInfo_リポジトリから取得したアセット情 storeMock .Setup(s => s.GetStream(asset)) .Returns(stream); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new AssetApplicationService(repositoryMock.Object, storeMock.Object, logger); // Act diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs index c567cef80..1cf2d746c 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs @@ -1,5 +1,4 @@ using Dressca.ApplicationCore.Baskets; -using Maris.Logging.Testing.Xunit; using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Baskets; @@ -7,12 +6,12 @@ namespace Dressca.UnitTests.ApplicationCore.Baskets; /// /// 買い物かごアプリケーションサービスの単体テストです。 /// -public class BasketApplicationServiceTest +public class BasketApplicationServiceTest : TestBase { - private readonly TestLoggerManager loggerManager; - public BasketApplicationServiceTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } private static CancellationToken AnyToken => It.IsAny(); @@ -24,7 +23,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 { // Arrange var repo = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repo, logger); // Act @@ -44,7 +43,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 repoMock .Setup(r => r.GetWithBasketItemsAsync(dummyBuyerId, AnyToken)) .ReturnsAsync((Basket?)null); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -63,7 +62,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 repoMock .Setup(r => r.GetWithBasketItemsAsync(buyerId, AnyToken)) .ReturnsAsync((Basket?)null); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -90,7 +89,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 repoMock .Setup(r => r.AddAsync(It.IsAny(), AnyToken)) .ReturnsAsync(newBasket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -106,7 +105,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 // Arrange var buyerId = Guid.NewGuid().ToString("D"); var repoMock = new Mock(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -126,7 +125,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごが取得でき repoMock .Setup(r => r.GetWithBasketItemsAsync(buyerId, AnyToken)) .ReturnsAsync(basket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -148,7 +147,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 repoMock .Setup(r => r.GetWithBasketItemsAsync(buyerId, AnyToken)) .ReturnsAsync(basket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -172,7 +171,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 repoMock .Setup(r => r.GetAsync(basketId, AnyToken)) .ReturnsAsync(basket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -192,7 +191,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 repoMock .Setup(r => r.GetAsync(basketId, AnyToken)) .ReturnsAsync(basket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -209,7 +208,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 { // Arrange var repo = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repo, logger); // Act @@ -231,7 +230,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 repoMock .Setup(r => r.GetAsync(basketId, AnyToken)) .ReturnsAsync(basket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -252,7 +251,7 @@ public async Task DeleteBasketAsync_買い物かごの削除処理はリポジ repoMock .Setup(r => r.GetWithBasketItemsAsync(basketId, AnyToken)) .ReturnsAsync(new Basket("dummy")); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -272,7 +271,7 @@ public async Task DeleteBasketAsync_買い物かごの削除処理はリポジ repoMock .Setup(r => r.GetWithBasketItemsAsync(basketId, AnyToken)) .ReturnsAsync(new Basket(buyerId)); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); // Act @@ -289,7 +288,7 @@ public async Task DeleteBasketAsync_買い物かごの削除処理で買い物 { // Arrange var repo = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repo, logger); // Act @@ -304,7 +303,7 @@ public async Task SetQuantitiesAsync_数量の設定処理で数量パラメー { // Arrange var repo = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repo, logger); // Act @@ -319,7 +318,7 @@ public async Task SetQuantitiesAsync_数量の設定処理で買い物かごが { // Arrange var repo = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repo, logger); var quantities = new Dictionary { { 1L, 1 }, { 2L, 1 }, { 3L, 1 } }; @@ -341,7 +340,7 @@ public async Task SetQuantitiesAsync_数量の設定処理はリポジトリのU repoMock .Setup(r => r.GetWithBasketItemsAsync(basketId, AnyToken)) .ReturnsAsync(new Basket(buyerId)); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); var quantities = new Dictionary { { 1L, 5 } }; @@ -365,7 +364,7 @@ public async Task SetQuantitiesAsync_買い物かごに存在しない商品を repoMock .Setup(r => r.GetWithBasketItemsAsync(basketId, AnyToken)) .ReturnsAsync(new Basket(buyerId)); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); var quantities = new Dictionary { { 1L, 5 } }; @@ -392,7 +391,7 @@ public async Task SetQuantitiesAsync_買い物かごに存在する商品を指 repoMock .Setup(r => r.GetWithBasketItemsAsync(basketId, AnyToken)) .ReturnsAsync(basket); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new BasketApplicationService(repoMock.Object, logger); var quantities = new Dictionary { { 100L, newQuantity } }; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs index 247ddc2b6..20374015e 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs @@ -1,6 +1,5 @@ using System.Linq.Expressions; using Dressca.ApplicationCore.Catalog; -using Maris.Logging.Testing.Xunit; using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Catalog; @@ -8,12 +7,12 @@ namespace Dressca.UnitTests.ApplicationCore.Catalog; /// /// カタログアプリケーションサービスの単体テストです。 /// -public class CatalogApplicationServiceTest +public class CatalogApplicationServiceTest : TestBase { - private readonly TestLoggerManager loggerManager; - public CatalogApplicationServiceTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } private static CancellationToken AnyToken => It.IsAny(); @@ -24,7 +23,7 @@ public async Task GetCatalogItemsAsync_カタログ取得処理はリポジト var catalogRepositoryMock = new Mock(); var catalogBrandRepository = Mock.Of(); var catalogCategoryRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, logger); const int skip = 1; const int take = 10; @@ -45,7 +44,7 @@ public async Task GetCatalogItemsAsync_カタログ取得処理はリポジト var catalogRepositoryMock = new Mock(); var catalogBrandRepository = Mock.Of(); var catalogCategoryRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, logger); // Act @@ -64,7 +63,7 @@ public async Task GetBrandsAsync_ブランド取得処理はブランドリポ var catalogRepository = Mock.Of(); var catalogBrandRepositoryMock = new Mock(); var catalogCategoryRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new CatalogApplicationService(catalogRepository, catalogBrandRepositoryMock.Object, catalogCategoryRepository, logger); // Act @@ -81,7 +80,7 @@ public async Task GetCategoriesAsync_カテゴリ取得処理はカテゴリリ var catalogRepository = Mock.Of(); var catalogBrandRepository = Mock.Of(); var catalogCategoryRepositoryMock = new Mock(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new CatalogApplicationService(catalogRepository, catalogBrandRepository, catalogCategoryRepositoryMock.Object, logger); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index 2eee4f18a..292bb8986 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -1,16 +1,15 @@ using System.Linq.Expressions; using Dressca.ApplicationCore.Catalog; -using Maris.Logging.Testing.Xunit; using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Catalog; -public class CatalogDomainServiceTest +public class CatalogDomainServiceTest : TestBase { - private readonly TestLoggerManager loggerManager; - public CatalogDomainServiceTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } private static CancellationToken AnyToken => It.IsAny(); @@ -28,7 +27,7 @@ public async Task ExistsAllAsync_カタログアイテムIdがすべて存在す .Setup(r => r.FindAsync(It.IsAny>>(), AnyToken)) .ReturnsAsync(catalogItems); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act @@ -55,7 +54,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 .Setup(r => r.FindAsync(It.IsAny>>(), AnyToken)) .ReturnsAsync(catalogItems); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act @@ -78,7 +77,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが1件も存在し .Setup(r => r.FindAsync(It.IsAny>>(), AnyToken)) .ReturnsAsync(catalogItems); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs index ad4da1277..5cd0c85c2 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs @@ -2,17 +2,16 @@ using Dressca.ApplicationCore.Baskets; using Dressca.ApplicationCore.Catalog; using Dressca.ApplicationCore.Ordering; -using Maris.Logging.Testing.Xunit; using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Ordering; -public class OrderApplicationServiceTest +public class OrderApplicationServiceTest : TestBase { - private readonly TestLoggerManager loggerManager; - public OrderApplicationServiceTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } private static CancellationToken AnyToken => It.IsAny(); @@ -41,7 +40,7 @@ public async Task CreateOrderAsync_注文作成処理は注文リポジトリの orderRepositoryMock .Setup(r => r.AddAsync(It.IsAny(), AnyToken)) .ReturnsAsync(new Order(buyerId, shipTo, CreateDefaultOrderItems())); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new OrderApplicationService(orderRepositoryMock.Object, basketRepositoryMock.Object, catalogRepositoryMock.Object, logger); // Act @@ -64,7 +63,7 @@ public async Task CreateOrderAsync_注文作成処理で指定した買い物か .ReturnsAsync((Basket?)null); var catalogRepository = Mock.Of(); var orderRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new OrderApplicationService(orderRepository, basketRepositoryMock.Object, catalogRepository, logger); var shipTo = CreateDefaultShipTo(); @@ -88,7 +87,7 @@ public async Task CreateOrderAsync_注文作成処理で指定した買い物か .ReturnsAsync(basket); var catalogRepository = Mock.Of(); var orderRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new OrderApplicationService(orderRepository, basketRepositoryMock.Object, catalogRepository, logger); var shipTo = CreateDefaultShipTo(); @@ -114,7 +113,7 @@ public async Task GetOrderAsync_注文リポジトリから取得した情報と .ReturnsAsync(order); var basketRepository = Mock.Of(); var catalogRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new OrderApplicationService(orderRepositoryMock.Object, basketRepository, catalogRepository, logger); // Act @@ -139,7 +138,7 @@ public async Task GetOrderAsync_注文リポジトリから取得した情報と .ReturnsAsync(order); var basketRepository = Mock.Of(); var catalogRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new OrderApplicationService(orderRepositoryMock.Object, basketRepository, catalogRepository, logger); // Act @@ -161,7 +160,7 @@ public async Task GetOrderAsync_注文リポジトリから注文情報を取得 .ReturnsAsync((Order?)null); var basketRepository = Mock.Of(); var catalogRepository = Mock.Of(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new OrderApplicationService(orderRepositoryMock.Object, basketRepository, catalogRepository, logger); // Act diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs index 440b1fd37..fb512aebd 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs @@ -1,6 +1,5 @@ using Dressca.SystemCommon; using Dressca.Web.Runtime; -using Maris.Logging.Testing.Xunit; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; @@ -12,12 +11,12 @@ namespace Dressca.UnitTests.Web.Runtime; -public class BusinessExceptionDevelopmentFilterTest +public class BusinessExceptionDevelopmentFilterTest : TestBase { - private readonly TestLoggerManager loggerManager; - public BusinessExceptionDevelopmentFilterTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } [Fact] public void OnException_業務エラーの情報がActionResultの値に設定される() @@ -84,7 +83,7 @@ private static ExceptionContext CreateExceptionContext(BusinessError businessErr private BusinessExceptionDevelopmentFilter CreateFilter() { var problemDetailsFactory = new TestProblemDetailsFactory(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); return new BusinessExceptionDevelopmentFilter(problemDetailsFactory, logger); } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs index 07a7dd343..008987851 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs @@ -12,12 +12,12 @@ namespace Dressca.UnitTests.Web.Runtime; -public class BusinessExceptionFilterTest +public class BusinessExceptionFilterTest : TestBase { - private readonly TestLoggerManager loggerManager; - public BusinessExceptionFilterTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } [Fact] public void OnException_業務エラーの情報がActionResultの値に設定される() @@ -84,7 +84,7 @@ private static ExceptionContext CreateExceptionContext(BusinessError businessErr private BusinessExceptionFilter CreateFilter() { var problemDetailsFactory = new TestProblemDetailsFactory(); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); return new BusinessExceptionFilter(problemDetailsFactory, logger); } From 4959c14d5be420811e3853edeca1b62ab9f9d832 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:25:50 +0900 Subject: [PATCH 03/40] =?UTF-8?q?ConsoleAppWithDI=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E5=90=88=E3=83=86=E3=82=B9=E3=83=88=E3=83=97=E3=83=AD=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AB=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=AE=E3=83=99=E3=83=BC=E3=82=B9=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Maris.ConsoleApp.IntegrationTests/TestBase.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/TestBase.cs diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/TestBase.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/TestBase.cs new file mode 100644 index 000000000..600dc88c1 --- /dev/null +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/TestBase.cs @@ -0,0 +1,15 @@ +using Maris.Logging.Testing.Xunit; +using Xunit.Abstractions; + +namespace Maris.ConsoleApp.IntegrationTests; + +public class TestBase +{ + protected TestBase(ITestOutputHelper testOutputHelper) + { + ArgumentNullException.ThrowIfNull(testOutputHelper); + this.LoggerManager = new TestLoggerManager(testOutputHelper); + } + + protected TestLoggerManager LoggerManager { get; } +} From 38134a67116b2269d4c14390fb9ef2d6fb438809 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:26:30 +0900 Subject: [PATCH 04/40] =?UTF-8?q?TestBase=E3=82=92=E4=BD=BF=E3=81=86?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=ABConsoleAppWithDI=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E5=90=88=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScopeTests/ScopedTest.cs | 11 +++++------ .../ScopeTests/SingletonTest.cs | 11 +++++------ .../ScopeTests/TransientTest.cs | 11 +++++------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs index 532143026..76d01f897 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs @@ -1,6 +1,5 @@ using Maris.ConsoleApp.Hosting; using Maris.ConsoleApp.IntegrationTests.ScopeTests.Commands; -using Maris.Logging.Testing.Xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Xunit.Abstractions; @@ -8,12 +7,12 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; [Collection(nameof(ScopeTests))] -public class ScopedTest +public class ScopedTest : TestBase { - private readonly TestLoggerManager loggerManager; - public ScopedTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } [Fact] public async Task Scopedで登録したインスタンスはコマンド実行時に1回だけ初期化される() @@ -127,7 +126,7 @@ private IHost CreateHost() var builder = Host.CreateDefaultBuilder(args); builder.ConfigureServices((context, services) => { - services.AddTestLogging(this.loggerManager); + services.AddTestLogging(this.LoggerManager); services.AddScoped(); // Command 内で利用 services.AddScoped(); // Command, TestObject1 内で利用 services.AddConsoleAppService(args); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs index 04a71729a..0e682496b 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs @@ -1,6 +1,5 @@ using Maris.ConsoleApp.Hosting; using Maris.ConsoleApp.IntegrationTests.ScopeTests.Commands; -using Maris.Logging.Testing.Xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Xunit.Abstractions; @@ -8,12 +7,12 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; [Collection(nameof(ScopeTests))] -public class SingletonTest +public class SingletonTest : TestBase { - private readonly TestLoggerManager loggerManager; - public SingletonTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } [Fact] public async Task Singletonで登録したインスタンスはコマンド実行時に1回だけ初期化される() @@ -127,7 +126,7 @@ private IHost CreateHost() var builder = Host.CreateDefaultBuilder(args); builder.ConfigureServices((context, services) => { - services.AddTestLogging(this.loggerManager); + services.AddTestLogging(this.LoggerManager); services.AddSingleton(); // Command 内で利用 services.AddSingleton(); // Command, TestObject1 内で利用 services.AddConsoleAppService(args); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs index 077352b54..f55cd5359 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs @@ -1,6 +1,5 @@ using Maris.ConsoleApp.Hosting; using Maris.ConsoleApp.IntegrationTests.ScopeTests.Commands; -using Maris.Logging.Testing.Xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Xunit.Abstractions; @@ -8,12 +7,12 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; [Collection(nameof(ScopeTests))] -public class TransientTest +public class TransientTest : TestBase { - private readonly TestLoggerManager loggerManager; - public TransientTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } [Fact] public async Task Transientで登録したインスタンスはインジェクション時に毎回初期化される() @@ -130,7 +129,7 @@ private IHost CreateHost() var builder = Host.CreateDefaultBuilder(args); builder.ConfigureServices((context, services) => { - services.AddTestLogging(this.loggerManager); + services.AddTestLogging(this.LoggerManager); services.AddTransient(); // Command 内で利用 services.AddTransient(); // Command, TestObject1 内で利用 services.AddConsoleAppService(args); From 182f2d05071105722db5b471edb6b52ae778b8a1 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:53:20 +0900 Subject: [PATCH 05/40] =?UTF-8?q?ConsoleAppWithDI=E3=81=AE=E5=8D=98?= =?UTF-8?q?=E4=BD=93=E3=83=86=E3=82=B9=E3=83=88=E3=83=97=E3=83=AD=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AB=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=AE=E3=83=99=E3=83=BC=E3=82=B9=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Maris.ConsoleApp.UnitTests/TestBase.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/TestBase.cs diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/TestBase.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/TestBase.cs new file mode 100644 index 000000000..b0e94889e --- /dev/null +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/TestBase.cs @@ -0,0 +1,22 @@ +using Maris.Logging.Testing.Xunit; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Testing; +using Xunit.Abstractions; + +namespace Maris.ConsoleApp.UnitTests; + +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(); +} From 102890ff3231b2acab2737f84ab7289957b08d1f Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:53:51 +0900 Subject: [PATCH 06/40] =?UTF-8?q?TestBase=E3=82=92=E4=BD=BF=E3=81=86?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=ABConsoleAppWithDI=E3=81=AE=E5=8D=98?= =?UTF-8?q?=E4=BD=93=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hosting/ConsoleAppHostedServiceTest.cs | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs index a0fbe2790..65530b9b9 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs @@ -1,18 +1,17 @@ using Maris.ConsoleApp.Core; using Maris.ConsoleApp.Hosting; -using Maris.Logging.Testing.Xunit; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Xunit.Abstractions; namespace Maris.ConsoleApp.UnitTests.Hosting; -public class ConsoleAppHostedServiceTest +public class ConsoleAppHostedServiceTest : TestBase { - private readonly TestLoggerManager loggerManager; - public ConsoleAppHostedServiceTest(ITestOutputHelper testOutputHelper) - => this.loggerManager = new TestLoggerManager(testOutputHelper); + : base(testOutputHelper) + { + } public static IEnumerable GetContextsAndCommands() { @@ -50,9 +49,9 @@ public void Constructor_lifetimeがnullの場合は例外() var settings = new ConsoleAppSettings(); var managerMock = CreateCommandManagerMock(); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); // Act var action = () => new ConsoleAppHostedService(lifetime!, settings, executor, logger); @@ -69,9 +68,9 @@ public void Constructor_settingsがnullの場合は例外() ConsoleAppSettings? settings = null; var managerMock = CreateCommandManagerMock(); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); // Act var action = () => new ConsoleAppHostedService(lifetime, settings!, executor, logger); @@ -87,7 +86,7 @@ public void Constructor_executorがnullの場合は例外() var lifetime = Mock.Of(); var settings = new ConsoleAppSettings(); CommandExecutor? executor = null; - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); // Act var action = () => new ConsoleAppHostedService(lifetime, settings, executor!, logger); @@ -104,7 +103,7 @@ public void Constructor_loggerがnullの場合は例外() var settings = new ConsoleAppSettings(); var managerMock = CreateCommandManagerMock(); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); ILogger? logger = null; @@ -129,9 +128,9 @@ public async Task StartAsync_コマンドが正常に完了するとコマンド command.Initialize(context); var managerMock = CreateCommandManagerMock(command); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new ConsoleAppHostedService(lifetime, settings, executor, logger); int actualExitCode = 0; service.SetExitCode = (exitCode) => actualExitCode = exitCode; @@ -158,9 +157,9 @@ public async Task StartAsync_コマンドの入力値エラーがあると設定 command.Initialize(context); var managerMock = CreateCommandManagerMock(command); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new ConsoleAppHostedService(lifetime, settings, executor, logger); int actualExitCode = 0; service.SetExitCode = (exitCode) => actualExitCode = exitCode; @@ -187,9 +186,9 @@ public async Task StartAsync_コマンドの実行時に例外が発生すると command.Initialize(context); var managerMock = CreateCommandManagerMock(command); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new ConsoleAppHostedService(lifetime, settings, executor, logger); int actualExitCode = 0; service.SetExitCode = (exitCode) => actualExitCode = exitCode; @@ -213,9 +212,9 @@ public async Task StartAsync_コマンドが完了するとIHostApplicationLifet command.Initialize(context); var managerMock = CreateCommandManagerMock(command); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new ConsoleAppHostedService(lifetime, settings, executor, logger); int actualExitCode = 0; service.SetExitCode = (exitCode) => actualExitCode = exitCode; @@ -236,9 +235,9 @@ public async Task StopAsync_例外が発生しない() var settings = new ConsoleAppSettings(); var managerMock = CreateCommandManagerMock(); var manager = managerMock.Object; - var commandExecutorLogger = this.loggerManager.CreateLogger(); + var commandExecutorLogger = this.CreateTestLogger(); var executor = new CommandExecutor(manager, commandExecutorLogger); - var logger = this.loggerManager.CreateLogger(); + var logger = this.CreateTestLogger(); var service = new ConsoleAppHostedService(lifetime, settings, executor, logger); var cancellationToken = new CancellationToken(false); From defbc2fe1063c3d1aef8b357929a34d4c2fe0f63 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:39:16 +0900 Subject: [PATCH 07/40] =?UTF-8?q?=E3=82=AB=E3=82=BF=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=81=8C=E8=A6=8B=E3=81=A4?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AA=E3=81=84=E3=81=A8=E3=81=8D=E3=81=AE?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=83=AC=E3=83=99=E3=83=AB=E3=82=92=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Dressca.ApplicationCore/Catalog/CatalogDomainService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Catalog/CatalogDomainService.cs b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Catalog/CatalogDomainService.cs index 9f8452719..4dc886d5c 100644 --- a/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Catalog/CatalogDomainService.cs +++ b/samples/Dressca/dressca-backend/src/Dressca.ApplicationCore/Catalog/CatalogDomainService.cs @@ -51,7 +51,7 @@ await this.catalogRepository.FindAsync( .ToArray(); if (notExistsCatalogItemIds.Any()) { - this.logger.LogWarning( + this.logger.LogInformation( Messages.CatalogItemIdDoesNotExistInRepository, string.Join(',', notExistsCatalogItemIds)); return (ExistsAll: false, CatalogItems: items); From c987d124d18bfb387b55cb56eb24126bbc14f0af Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:40:58 +0900 Subject: [PATCH 08/40] =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=81=AE=E5=87=BA=E5=8A=9B=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99?= =?UTF-8?q?=E3=82=8B=E5=8D=98=E4=BD=93=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Catalog/CatalogDomainServiceTest.cs | 58 ++++++++++++++++++- .../BusinessExceptionDevelopmentFilterTest.cs | 24 ++++++++ .../Runtime/BusinessExceptionFilterTest.cs | 24 ++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index 292bb8986..af398859c 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -1,5 +1,6 @@ using System.Linq.Expressions; using Dressca.ApplicationCore.Catalog; +using Microsoft.Extensions.Logging; using Xunit.Abstractions; namespace Dressca.UnitTests.ApplicationCore.Catalog; @@ -14,7 +15,7 @@ public CatalogDomainServiceTest(ITestOutputHelper testOutputHelper) private static CancellationToken AnyToken => It.IsAny(); [Fact] - public async Task ExistsAllAsync_カタログアイテムIdがすべて存在する場合() + public async Task ExistsAllAsync_カタログアイテムIdがすべて存在する場合_existsAllはfalse_itemsは見つかったカタログアイテムのリスト() { // Arrange var catalogRepositoryMock = new Mock(); @@ -42,7 +43,7 @@ public async Task ExistsAllAsync_カタログアイテムIdがすべて存在す } [Fact] - public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する場合() + public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する場合_existsAllはfalse_itemsは見つかったカタログアイテムのリスト() { // Arrange var catalogRepositoryMock = new Mock(); @@ -68,7 +69,34 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 } [Fact] - public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない場合() + public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する場合_情報ログが1件出る() + { + // Arrange + var catalogRepositoryMock = new Mock(); + var catalogItems = new List + { + CreateCatalogItem(2L), + }; + catalogRepositoryMock + .Setup(r => r.FindAsync(It.IsAny>>(), AnyToken)) + .ReturnsAsync(catalogItems); + + var logger = this.CreateTestLogger(); + var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); + + // Act + _ = await domainService.ExistsAllAsync(new[] { 1L, 2L }); + + // Assert + Assert.Equal(1, this.LogCollector.Count); + var record = this.LogCollector.LatestRecord; + Assert.Equal("指定されたカタログアイテム ID: [1] のカタログアイテムがリポジトリに存在しません。", record.Message); + Assert.Equal(LogLevel.Information, record.Level); + Assert.Equal(new EventId(0), record.Id); + } + + [Fact] + public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない場合_existsAllはfalse_itemsは空() { // Arrange var catalogRepositoryMock = new Mock(); @@ -88,6 +116,30 @@ public async Task ExistsAllAsync_カタログアイテムIdが1件も存在し Assert.Empty(items); } + [Fact] + public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない場合_情報ログが1件出る() + { + // Arrange + var catalogRepositoryMock = new Mock(); + var catalogItems = new List(); + catalogRepositoryMock + .Setup(r => r.FindAsync(It.IsAny>>(), AnyToken)) + .ReturnsAsync(catalogItems); + + var logger = this.CreateTestLogger(); + var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); + + // Act + _ = await domainService.ExistsAllAsync(new[] { 1L }); + + // Assert + Assert.Equal(1, this.LogCollector.Count); + var record = this.LogCollector.LatestRecord; + Assert.Equal("指定されたカタログアイテム ID: [1] のカタログアイテムがリポジトリに存在しません。", record.Message); + Assert.Equal(LogLevel.Information, record.Level); + Assert.Equal(new EventId(0), record.Id); + } + private static CatalogItem CreateCatalogItem(long id) { var random = new Random(); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs index fb512aebd..c32b3f010 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Logging; using Xunit.Abstractions; namespace Dressca.UnitTests.Web.Runtime; @@ -67,6 +68,29 @@ public void OnException_業務例外のスタックトレースがdetailに設 Assert.Equal(context.Exception.ToString(), value.Detail); } + [Fact] + public void OnException_情報ログが1件登録される() + { + // Arrange + var filter = this.CreateFilter(); + var errorCode = "ERR_CODE"; + var errorMessage1 = "ERR_MESSAGE1"; + var errorMessage2 = "ERR_MESSAGE2"; + var businessError = new BusinessError(errorCode, errorMessage1, errorMessage2); + var context = CreateExceptionContext(businessError); + + // Act + filter.OnException(context); + + // Assert + Assert.Equal(1, this.LogCollector.Count); + var record = this.LogCollector.LatestRecord; + Assert.Equal("業務エラーが発生しました。", record.Message); + Assert.Equal(LogLevel.Information, record.Level); + Assert.Equal(new EventId(0), record.Id); + Assert.Same(context.Exception, record.Exception); + } + private static ExceptionContext CreateExceptionContext(BusinessError businessError) { var httpContext = new DefaultHttpContext(); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs index 008987851..33107753f 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Logging; using Xunit.Abstractions; namespace Dressca.UnitTests.Web.Runtime; @@ -68,6 +69,29 @@ public void OnException_業務例外のスタックトレースがdetailに設 Assert.Null(value.Detail); } + [Fact] + public void OnException_情報ログが1件登録される() + { + // Arrange + var filter = this.CreateFilter(); + var errorCode = "ERR_CODE"; + var errorMessage1 = "ERR_MESSAGE1"; + var errorMessage2 = "ERR_MESSAGE2"; + var businessError = new BusinessError(errorCode, errorMessage1, errorMessage2); + var context = CreateExceptionContext(businessError); + + // Act + filter.OnException(context); + + // Assert + Assert.Equal(1, this.LogCollector.Count); + var record = this.LogCollector.LatestRecord; + Assert.Equal("業務エラーが発生しました。", record.Message); + Assert.Equal(LogLevel.Information, record.Level); + Assert.Equal(new EventId(0), record.Id); + Assert.Same(context.Exception, record.Exception); + } + private static ExceptionContext CreateExceptionContext(BusinessError businessError) { var httpContext = new DefaultHttpContext(); From dfa1747568f5b11e49c615cee6d446db87d1655b Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:08:36 +0900 Subject: [PATCH 09/40] =?UTF-8?q?LiveUnitTesting=E3=81=AE=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E9=99=A4?= =?UTF-8?q?=E5=A4=96=E8=A8=AD=E5=AE=9A=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/Dressca/dressca-backend/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/Dressca/dressca-backend/.gitignore b/samples/Dressca/dressca-backend/.gitignore index 1ee53850b..a6a014765 100644 --- a/samples/Dressca/dressca-backend/.gitignore +++ b/samples/Dressca/dressca-backend/.gitignore @@ -9,6 +9,7 @@ *.user *.userosscache *.sln.docstates +*.lutconfig # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs From fb295ac6ecbb63096c0a7c31797071a7cd735b9a Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:10:05 +0900 Subject: [PATCH 10/40] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=AE=E5=AE=9F=E8=A3=85=E3=83=91=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E3=81=A7=E6=8A=B5=E8=A7=A6=E3=81=99=E3=82=8B?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=83=AC=E3=83=99=E3=83=AB=E3=81=AE=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E9=80=9A=E7=9F=A5=E3=82=92=E7=84=A1=E5=8A=B9?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/Dressca/dressca-backend/tests/.editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/Dressca/dressca-backend/tests/.editorconfig b/samples/Dressca/dressca-backend/tests/.editorconfig index c5142fde3..b8668a97c 100644 --- a/samples/Dressca/dressca-backend/tests/.editorconfig +++ b/samples/Dressca/dressca-backend/tests/.editorconfig @@ -1,5 +1,6 @@ [*.cs] # Wrapping preferences +dotnet_diagnostic.IDE0039.severity=none dotnet_diagnostic.SA0001.severity=none dotnet_diagnostic.SA1123.severity=none dotnet_diagnostic.SA1600.severity=none From 9b875bb9e846085094e1a97da519bf959a48e18d Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:31:25 +0900 Subject: [PATCH 11/40] =?UTF-8?q?Dressca.UnitTests=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=90=8D?= =?UTF-8?q?=E3=81=A7=E3=83=86=E3=82=B9=E3=83=88=E4=BB=95=E6=A7=98=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=8F=BE=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationCore/Accounting/AccountTest.cs | 14 +++++----- .../Assets/AssetApplicationServiceTest.cs | 4 +-- .../ApplicationCore/Assets/AssetTest.cs | 4 +-- .../ApplicationCore/Assets/AssetTypesTest.cs | 4 +-- .../Baskets/BasketApplicationServiceTest.cs | 26 +++++++++---------- .../ApplicationCore/Baskets/BasketItemTest.cs | 2 +- .../ApplicationCore/Baskets/BasketTest.cs | 26 +++++++++---------- .../Catalog/CatalogApplicationServiceTest.cs | 8 +++--- .../Catalog/CatalogBrandTest.cs | 2 +- .../Catalog/CatalogCategoryTest.cs | 2 +- .../Catalog/CatalogDomainServiceTest.cs | 10 +++---- .../Catalog/CatalogItemAssetTest.cs | 4 +-- .../ApplicationCore/Ordering/AddressTest.cs | 8 +++--- .../Ordering/CatalogItemOrderedTest.cs | 6 ++--- .../Ordering/OrderApplicationServiceTest.cs | 12 ++++----- .../Ordering/OrderItemAssetTest.cs | 4 +-- .../ApplicationCore/Ordering/OrderItemTest.cs | 6 ++--- .../ApplicationCore/Ordering/OrderTest.cs | 6 ++--- .../ApplicationCore/Ordering/ShipToTest.cs | 4 +-- .../BusinessErrorCollectionTest.cs | 2 +- .../SystemCommon/BusinessErrorTest.cs | 2 +- .../SystemCommon/BusinessExceptionTest.cs | 2 +- .../SystemCommon/ObjectExtensionsTest.cs | 4 +-- .../Web/Assets/AssetExtensionsTest.cs | 4 +-- .../Web/Baskets/HttpContextExtensionsTest.cs | 8 +++--- 25 files changed, 87 insertions(+), 87 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Accounting/AccountTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Accounting/AccountTest.cs index a917b1cc7..174317ecd 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Accounting/AccountTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Accounting/AccountTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.ApplicationCore.Accounting; public class AccountTest { [Fact] - public void Constructor_会計アイテムがnullの場合例外() + public void Constructor_会計アイテムがnull_ArgumentNullExceptionが発生する() { // Arrange IEnumerable? accountItems = null; @@ -18,7 +18,7 @@ public void Constructor_会計アイテムがnullの場合例外() } [Fact] - public void GetItemsTotalPrice_会計アイテムがないとき会計アイムの合計金額は0円() + public void GetItemsTotalPrice_会計アイテムがない_合計金額は0円() { // Arrange var account = new Account(Array.Empty()); @@ -31,7 +31,7 @@ public void GetItemsTotalPrice_会計アイテムがないとき会計アイム } [Fact] - public void GetItemsTotalPrice_会計アイテムが1件あるとき会計アイムの合計金額は送料と消費税をのぞく合計金額になる() + public void GetItemsTotalPrice_会計アイテムが1件ある_合計金額は送料と消費税をのぞく合計金額になる() { // Arrange var accountItems = new AccountItem[] { new(5, 300m) }; @@ -45,7 +45,7 @@ public void GetItemsTotalPrice_会計アイテムが1件あるとき会計アイ } [Fact] - public void GetItemsTotalPrice_会計アイテムが2件あるとき会計アイムの合計金額は送料と消費税をのぞく合計金額になる() + public void GetItemsTotalPrice_会計アイテムが2件ある_合計金額は送料と消費税をのぞく合計金額になる() { // Arrange var accountItems = new AccountItem[] @@ -63,7 +63,7 @@ public void GetItemsTotalPrice_会計アイテムが2件あるとき会計アイ } [Fact] - public void GetDeliveryCharge_会計アイテムがないとき送料は0円() + public void GetDeliveryCharge_会計アイテムがない_送料は0円() { // Arrange var account = new Account(Array.Empty()); @@ -76,7 +76,7 @@ public void GetDeliveryCharge_会計アイテムがないとき送料は0円() } [Fact] - public void GetDeliveryCharge_会計アイムの合計金額が5000円未満の場合は送料が500円になる() + public void GetDeliveryCharge_会計アイテムの合計金額が5000円未満_送料が500円() { // Arrange var accountItems = new AccountItem[] { new(1, 4999m) }; @@ -90,7 +90,7 @@ public void GetDeliveryCharge_会計アイムの合計金額が5000円未満の } [Fact] - public void GetDeliveryCharge_会計アイムの合計金額が5000円以上の場合は送料が0円になる() + public void GetDeliveryCharge_会計アイテムの合計金額が5000円以上_送料が0円() { // Arrange var accountItems = new AccountItem[] { new(1, 5000m) }; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs index e6efafbf4..2b2730c4d 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs @@ -11,7 +11,7 @@ public AssetApplicationServiceTest(ITestOutputHelper testOutputHelper) } [Fact] - public void GetAssetStreamInfo_リポジトリに指定したアセットコードの情報が見つからない場合は例外() + public void GetAssetStreamInfo_リポジトリに指定したアセットコードの情報が見つからない_AssetNotFoundExceptionが発生する() { // Arrange var assetCode = "dummy"; @@ -32,7 +32,7 @@ public void GetAssetStreamInfo_リポジトリに指定したアセットコー } [Fact] - public void GetAssetStreamInfo_ストアに指定したアセットコードのストリームが見つからない場合は例外() + public void GetAssetStreamInfo_ストアに指定したアセットコードのストリームが見つからない場合_AssetNotFoundExceptionが発生する() { // Arrange var assetCode = "dummy"; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTest.cs index d0c728405..14c034267 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTest.cs @@ -8,7 +8,7 @@ public class AssetTest [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_アセットコードがnullまたは空の文字列の場合例外(string? assetCode) + public void Constructor_アセットコードがnullまたは空の文字列_ArgumentExceptionが発生する(string? assetCode) { // Arrange var assetType = AssetTypes.Png; @@ -22,7 +22,7 @@ public void Constructor_アセットコードがnullまたは空の文字列の } [Fact] - public void Constructor_アセットタイプが未知の場合例外() + public void Constructor_アセットタイプが未知_NotSupportedExceptionが発生する() { // Arrange var assetCode = "assetCode"; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTypesTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTypesTest.cs index ea221a622..d2addd4ef 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTypesTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetTypesTest.cs @@ -8,7 +8,7 @@ public class AssetTypesTest [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void IsSupportedAssetType_アセットタイプがnullまたは空の文字列の場合(string? assetType) + public void IsSupportedAssetType_アセットタイプがnullまたは空の文字列_false(string? assetType) { // Arrange: Do Nothing // Act @@ -20,7 +20,7 @@ public void IsSupportedAssetType_アセットタイプがnullまたは空の文 [Theory] [InlineData(AssetTypes.Png)] - public void IsSupportedAssetType_アセットタイプが定義済みの場合(string assetType) + public void IsSupportedAssetType_アセットタイプが定義済み_true(string assetType) { // Arrange: Do Nothing // Act diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs index 1cf2d746c..829f30fe4 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs @@ -19,7 +19,7 @@ public BasketApplicationServiceTest(ITestOutputHelper testOutputHelper) [InlineData(null)] [InlineData("")] [InlineData(" ")] - public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idがnullまたは空白なら例外が発生する(string? nullOrEmptyBuyerId) + public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idがnullまたは空白_ArgumentExceptionが発生する(string? nullOrEmptyBuyerId) { // Arrange var repo = Mock.Of(); @@ -35,7 +35,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 } [Fact] - public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idに対応する買い物かご情報が存在しない場合買い物かごの作成処理としてリポジトリのGetWithBasketItemsを1度だけ呼出す() + public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idに対応する買い物かご情報が存在しない_買い物かごの作成処理としてリポジトリのGetWithBasketItemsを1度だけ呼出す() { // Arrange const string dummyBuyerId = "dummyId"; @@ -54,7 +54,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 } [Fact] - public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idに対応する買い物かご情報が存在しない場合買い物かごの作成処理としてリポジトリのAddAsyncを1度だけ呼出す() + public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idに対応する買い物かご情報が存在しない_買い物かごの作成処理としてリポジトリのAddAsyncを1度だけ呼出す() { // Arrange const string buyerId = "not-exists-Id"; @@ -77,7 +77,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 } [Fact] - public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idに対応する買い物かご情報が存在しない場合AddAsyncで生成した買い物かごを取得できる() + public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理で購入者Idに対応する買い物かご情報が存在しない_AddAsyncで生成した買い物かごを取得できる() { // Arrange const string buyerId = "not-exists-Id"; @@ -116,7 +116,7 @@ public async Task GetOrCreateBasketForUserAsync_買い物かごの取得処理 } [Fact] - public async Task GetOrCreateBasketForUserAsync_買い物かごが取得できたときはリポジトリのAddAsyncを呼び出さない() + public async Task GetOrCreateBasketForUserAsync_買い物かごが取得できた_リポジトリのAddAsyncを呼び出さない() { // Arrange var buyerId = Guid.NewGuid().ToString("D"); @@ -204,7 +204,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 } [Fact] - public async Task AddItemToBasketAsync_買い物かごへの商品追加処理で買い物かごが見つからない場合は業務例外が発生する() + public async Task AddItemToBasketAsync_買い物かごへの商品追加処理で買い物かごが見つからない_BasketNotFoundExceptionが発生する() { // Arrange var repo = Mock.Of(); @@ -219,7 +219,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 } [Fact] - public async Task AddItemToBasketAsync_買い物かごへの商品追加処理後に数量が0となる場合買い物かごアイテムは削除される() + public async Task AddItemToBasketAsync_買い物かごへの商品追加処理後に数量が0となる_買い物かごアイテムは削除される() { // Arrange const long basketId = 1; @@ -284,7 +284,7 @@ public async Task DeleteBasketAsync_買い物かごの削除処理はリポジ } [Fact] - public async Task DeleteBasketAsync_買い物かごの削除処理で買い物かごが見つからない場合は業務例外が発生する() + public async Task DeleteBasketAsync_買い物かごの削除処理で買い物かごが見つからない_BasketNotFoundExceptionが発生する() { // Arrange var repo = Mock.Of(); @@ -299,7 +299,7 @@ public async Task DeleteBasketAsync_買い物かごの削除処理で買い物 } [Fact] - public async Task SetQuantitiesAsync_数量の設定処理で数量パラメータがnullならArgumentNullExceptionが発生する() + public async Task SetQuantitiesAsync_数量パラメータがnull_ArgumentNullExceptionが発生する() { // Arrange var repo = Mock.Of(); @@ -314,7 +314,7 @@ public async Task SetQuantitiesAsync_数量の設定処理で数量パラメー } [Fact] - public async Task SetQuantitiesAsync_数量の設定処理で買い物かごが見つからないなら業務例外が発生する() + public async Task SetQuantitiesAsync_買い物かごが見つからない_BasketNotFoundExceptionが発生する() { // Arrange var repo = Mock.Of(); @@ -331,7 +331,7 @@ public async Task SetQuantitiesAsync_数量の設定処理で買い物かごが } [Fact] - public async Task SetQuantitiesAsync_数量の設定処理はリポジトリのUpdateAsyncを1度だけ呼出す() + public async Task SetQuantitiesAsync_リポジトリのUpdateAsyncを1度だけ呼出す() { // Arrange const long basketId = 1L; @@ -355,7 +355,7 @@ public async Task SetQuantitiesAsync_数量の設定処理はリポジトリのU } [Fact] - public async Task SetQuantitiesAsync_買い物かごに存在しない商品を指定しても買い物かごには追加されない() + public async Task SetQuantitiesAsync_買い物かごに存在しない商品を指定_買い物かごには追加されない() { // Arrange const long basketId = 1L; @@ -379,7 +379,7 @@ public async Task SetQuantitiesAsync_買い物かごに存在しない商品を } [Fact] - public async Task SetQuantitiesAsync_買い物かごに存在する商品を指定すると買い物かごの商品数が更新される() + public async Task SetQuantitiesAsync_買い物かごに存在する商品を指定_買い物かごの商品数が更新される() { // Arrange const long basketId = 1L; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketItemTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketItemTest.cs index c4bfd9c6d..0b31b49d6 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketItemTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketItemTest.cs @@ -21,7 +21,7 @@ public void GetSubTotal_買い物かごアイテムの小計額は単価と数 } [Fact] - public void Basket_買い物かごのナビゲーションプロパティが初期化されていない場合例外() + public void Basket_買い物かごのナビゲーションプロパティが初期化されていない_InvalidOperationExceptionが発生する() { // Arrange long catalogItemId = 1L; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs index a43c3d853..ca56fb5f6 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs @@ -132,7 +132,7 @@ public void AddItem_買い物かご内の商品の数量を減算できる(int f } [Fact] - public void RemoveEmptyItems_買い物かごにアイテムが1件も存在しないとき数量0のアイテムを除去する() + public void RemoveEmptyItems_買い物かごにアイテムが1件も存在しない_アイテムは0件のまま() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -145,7 +145,7 @@ public void RemoveEmptyItems_買い物かごにアイテムが1件も存在し } [Fact] - public void RemoveEmptyItems_買い物かごに数量1のアイテムが1件存在するとき数量0のアイテムを除去する() + public void RemoveEmptyItems_買い物かごに数量1のアイテムが1件存在する_アイテムは変化しない() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -165,7 +165,7 @@ public void RemoveEmptyItems_買い物かごに数量1のアイテムが1件存 } [Fact] - public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件存在するとき数量0のアイテムを除去する() + public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件存在する_数量0のアイテムを除去する() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -179,7 +179,7 @@ public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件存 } [Fact] - public void RemoveEmptyItems_買い物かごに数量0のアイテムが2件存在するとき数量0のアイテムを除去する() + public void RemoveEmptyItems_買い物かごに数量0のアイテムが2件存在する_数量0のアイテムを除去する() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -194,7 +194,7 @@ public void RemoveEmptyItems_買い物かごに数量0のアイテムが2件存 } [Fact] - public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件_数量1のアイテムが1件存在するとき_数量0のアイテムを除去する() + public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件_数量1のアイテムが1件存在する_数量0のアイテムを除去する() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -215,7 +215,7 @@ public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件_数 } [Fact] - public void RemoveEmptyItems_買い物かごに数量1のアイテムが2件存在するとき数量0のアイテムを除去する() + public void RemoveEmptyItems_買い物かごに数量1のアイテムが2件存在する_アイテムは変化しない() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -264,7 +264,7 @@ public void RemoveEmptyItems_数量0の商品を買い物かごから削除し } [Fact] - public void AddItem_数量は0未満にできない() + public void AddItem_数量は0未満にする_ArgumentExceptionが発生する() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -280,7 +280,7 @@ public void AddItem_数量は0未満にできない() [Theory] [InlineData(10, -11)] [InlineData(10, 2147483647)] - public void AddItem_商品の数量を加減算して0未満にはできない(int firstQuantity, int additionalQuantity) + public void AddItem_商品の数量を加減算して0未満にする_ArgumentExceptionが発生する(int firstQuantity, int additionalQuantity) { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -295,7 +295,7 @@ public void AddItem_商品の数量を加減算して0未満にはできない(i } [Fact] - public void Constructor_買い物かごの購入者Idはnullにできない() + public void Constructor_買い物かごの購入者Idをnullにする_ArgumentNullExceptionが発生する() { // Arrange & Act var action = () => new Basket(null!); @@ -305,7 +305,7 @@ public void Constructor_買い物かごの購入者Idはnullにできない() } [Fact] - public void IsInCatalogItem_買い物かご内に存在するカタログアイテムIdを渡す() + public void IsInCatalogItem_買い物かご内に存在するカタログアイテムIdを渡す_true() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -319,7 +319,7 @@ public void IsInCatalogItem_買い物かご内に存在するカタログアイ } [Fact] - public void IsInCatalogItem_買い物かご内に存在しないカタログアイテムIdを渡す() + public void IsInCatalogItem_買い物かご内に存在しないカタログアイテムIdを渡す_false() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -348,7 +348,7 @@ public void GetAccount_買い物かごアイテムの情報をもとにした会 } [Fact] - public void IsEmpty_買い物かごアイテムが空である() + public void IsEmpty_買い物かごアイテムが空_true() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); @@ -361,7 +361,7 @@ public void IsEmpty_買い物かごアイテムが空である() } [Fact] - public void IsEmpty_買い物かごにアイテムが存在する() + public void IsEmpty_買い物かごにアイテムが存在する_false() { // Arrange var basket = new Basket(Guid.NewGuid().ToString()); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs index 20374015e..f29944614 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs @@ -17,7 +17,7 @@ public CatalogApplicationServiceTest(ITestOutputHelper testOutputHelper) private static CancellationToken AnyToken => It.IsAny(); [Fact] - public async Task GetCatalogItemsAsync_カタログ取得処理はリポジトリのFindを1回呼出す() + public async Task GetCatalogItemsAsync_リポジトリのFindAsyncを1回呼出す() { // Arrange var catalogRepositoryMock = new Mock(); @@ -38,7 +38,7 @@ public async Task GetCatalogItemsAsync_カタログ取得処理はリポジト } [Fact] - public async Task GetCatalogItemsAsync_カタログ取得処理はリポジトリのCountを1回呼出す() + public async Task GetCatalogItemsAsync_リポジトリのCountAsyncを1回呼出す() { // Arrange var catalogRepositoryMock = new Mock(); @@ -57,7 +57,7 @@ public async Task GetCatalogItemsAsync_カタログ取得処理はリポジト } [Fact] - public async Task GetBrandsAsync_ブランド取得処理はブランドリポジトリのGetAllを1回呼出す() + public async Task GetBrandsAsync_ブランドリポジトリのGetAllAsyncを1回呼出す() { // Arrange var catalogRepository = Mock.Of(); @@ -74,7 +74,7 @@ public async Task GetBrandsAsync_ブランド取得処理はブランドリポ } [Fact] - public async Task GetCategoriesAsync_カテゴリ取得処理はカテゴリリポジトリのGetAllを1回呼出す() + public async Task GetCategoriesAsync_カテゴリリポジトリのGetAllAsyncを1回呼出す() { // Arrange var catalogRepository = Mock.Of(); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogBrandTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogBrandTest.cs index 744d5e26b..842ed72d6 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogBrandTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogBrandTest.cs @@ -21,7 +21,7 @@ public void Constructor_正しくインスタンス化できる() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_ブランド名は必須(string? brandName) + public void Constructor_ブランド名がnullまたは空白文字_ArgumentExceptionが発生する(string? brandName) { // Arrange & Act var action = () => new CatalogBrand(brandName!); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogCategoryTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogCategoryTest.cs index 6b22b94ff..53b08abc9 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogCategoryTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogCategoryTest.cs @@ -21,7 +21,7 @@ public void Constructor_正しくインスタンス化できる() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_カテゴリ名は必須(string? categoryName) + public void Constructor_カテゴリ名がnullまたは空白文字_ArgumentExceptionが発生する(string? categoryName) { // Arrange & Act var action = () => new CatalogCategory(categoryName!); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index af398859c..e8fc8c12b 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -15,7 +15,7 @@ public CatalogDomainServiceTest(ITestOutputHelper testOutputHelper) private static CancellationToken AnyToken => It.IsAny(); [Fact] - public async Task ExistsAllAsync_カタログアイテムIdがすべて存在する場合_existsAllはfalse_itemsは見つかったカタログアイテムのリスト() + public async Task ExistsAllAsync_カタログアイテムIdがすべて存在する_existsAllはfalse_itemsは見つかったカタログアイテムのリスト() { // Arrange var catalogRepositoryMock = new Mock(); @@ -43,7 +43,7 @@ public async Task ExistsAllAsync_カタログアイテムIdがすべて存在す } [Fact] - public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する場合_existsAllはfalse_itemsは見つかったカタログアイテムのリスト() + public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する_existsAllはfalse_itemsは見つかったカタログアイテムのリスト() { // Arrange var catalogRepositoryMock = new Mock(); @@ -69,7 +69,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 } [Fact] - public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する場合_情報ログが1件出る() + public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在する_情報ログが1件出る() { // Arrange var catalogRepositoryMock = new Mock(); @@ -96,7 +96,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 } [Fact] - public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない場合_existsAllはfalse_itemsは空() + public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない_existsAllはfalse_itemsは空() { // Arrange var catalogRepositoryMock = new Mock(); @@ -117,7 +117,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが1件も存在し } [Fact] - public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない場合_情報ログが1件出る() + public async Task ExistsAllAsync_カタログアイテムIdが1件も存在しない_情報ログが1件出る() { // Arrange var catalogRepositoryMock = new Mock(); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogItemAssetTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogItemAssetTest.cs index 47f663a5e..00915d396 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogItemAssetTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogItemAssetTest.cs @@ -8,7 +8,7 @@ public class CatalogItemAssetTest [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_アセットコードがnullまたは空の文字列の場合例外(string? assetCode) + public void Constructor_アセットコードがnullまたは空の文字列_ArgumentExceptionが発生する(string? assetCode) { // Arrange var catalogItemId = 1L; @@ -22,7 +22,7 @@ public void Constructor_アセットコードがnullまたは空の文字列の } [Fact] - public void CatalogItem_カタログアイテムが初期化されていない場合例外() + public void CatalogItem_カタログアイテムが初期化されていない_InvalidOperationExceptionが発生する() { // Arrange string assetCode = "Asset Code"; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/AddressTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/AddressTest.cs index f559c3196..f6e615a1a 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/AddressTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/AddressTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.ApplicationCore.Ordering; public class AddressTest { [Fact] - public void Constructor_郵便番号がnullの場合例外() + public void Constructor_郵便番号がnull_ArgumentNullExceptionが発生する() { // Arrange string? postalCode = null; @@ -21,7 +21,7 @@ public void Constructor_郵便番号がnullの場合例外() } [Fact] - public void Constructor_都道府県がnullの場合例外() + public void Constructor_都道府県がnull_ArgumentNullExceptionが発生する() { // Arrange string postalCode = "100-8924"; @@ -37,7 +37,7 @@ public void Constructor_都道府県がnullの場合例外() } [Fact] - public void Constructor_市区町村がnullの場合例外() + public void Constructor_市区町村がnull_ArgumentNullExceptionが発生する() { // Arrange string postalCode = "100-8924"; @@ -53,7 +53,7 @@ public void Constructor_市区町村がnullの場合例外() } [Fact] - public void Constructor_字がnullの場合例外() + public void Constructor_字がnull_ArgumentNullExceptionが発生する() { // Arrange string postalCode = "100-8924"; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/CatalogItemOrderedTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/CatalogItemOrderedTest.cs index 54af84c9b..53c877f21 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/CatalogItemOrderedTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/CatalogItemOrderedTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.ApplicationCore.Ordering; public class CatalogItemOrderedTest { [Fact] - public void Constructor_カタログアイテムIdが0以下の場合例外() + public void Constructor_カタログアイテムIdが0以下_ArgumentOutOfRangeExceptionが発生する() { // Arrange long catalogItemId = 0L; @@ -25,7 +25,7 @@ public void Constructor_カタログアイテムIdが0以下の場合例外() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_製品名がnullまたは空の文字列の場合例外(string? productName) + public void Constructor_製品名がnullまたは空の文字列_ArgumentExceptionが発生する(string? productName) { // Arrange long catalogItemId = 1L; @@ -43,7 +43,7 @@ public void Constructor_製品名がnullまたは空の文字列の場合例外( [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_製品コードがnullまたは空の文字列の場合例外(string? productCode) + public void Constructor_製品コードがnullまたは空の文字列_ArgumentExceptionが発生する(string? productCode) { // Arrange long catalogItemId = 1L; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs index 5cd0c85c2..ab0015b0f 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs @@ -16,7 +16,7 @@ public OrderApplicationServiceTest(ITestOutputHelper testOutputHelper) private static CancellationToken AnyToken => It.IsAny(); [Fact] - public async Task CreateOrderAsync_注文作成処理は注文リポジトリのAddを1回呼出す() + public async Task CreateOrderAsync_注文リポジトリのAddAsyncを1回呼出す() { // Arrange const long basketId = 1L; @@ -53,7 +53,7 @@ public async Task CreateOrderAsync_注文作成処理は注文リポジトリの } [Fact] - public async Task CreateOrderAsync_注文作成処理で指定した買い物かごが存在しない場合は業務例外が発生する() + public async Task CreateOrderAsync_注文作成処理で指定した買い物かごが存在しない_BasketNotFoundExceptionが発生する() { // Arrange const long basketId = 999L; @@ -75,7 +75,7 @@ public async Task CreateOrderAsync_注文作成処理で指定した買い物か } [Fact] - public async Task CreateOrderAsync_注文作成処理で指定した買い物かごが空の場合は業務例外が発生する() + public async Task CreateOrderAsync_注文作成処理で指定した買い物かごが空_EmptyBasketOnCheckoutExceptionが発生する() { // Arrange const long basketId = 3L; @@ -99,7 +99,7 @@ public async Task CreateOrderAsync_注文作成処理で指定した買い物か } [Fact] - public async Task GetOrderAsync_注文リポジトリから取得した情報と指定した購入者IDが合致する場合注文情報を取得できる() + public async Task GetOrderAsync_注文リポジトリから取得した情報と指定した購入者IDが合致する_注文情報を取得できる() { // Arrange var orderId = 10L; @@ -124,7 +124,7 @@ public async Task GetOrderAsync_注文リポジトリから取得した情報と } [Fact] - public async Task GetOrderAsync_注文リポジトリから取得した情報と指定した購入者IDが異なる場合例外になる() + public async Task GetOrderAsync_注文リポジトリから取得した情報と指定した購入者IDが異なる_OrderNotFoundExceptionが発生する() { // Arrange var orderId = 10L; @@ -149,7 +149,7 @@ public async Task GetOrderAsync_注文リポジトリから取得した情報と } [Fact] - public async Task GetOrderAsync_注文リポジトリから注文情報を取得できない場合例外になる() + public async Task GetOrderAsync_注文リポジトリから注文情報を取得できない_OrderNotFoundExceptionが発生する() { // Arrange var orderId = 10L; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemAssetTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemAssetTest.cs index eb2a9a0c4..5992befdb 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemAssetTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemAssetTest.cs @@ -8,7 +8,7 @@ public class OrderItemAssetTest [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_アセットコードがnullまたは空の文字列の場合例外(string? assetCode) + public void Constructor_アセットコードがnullまたは空の文字列_ArgumentExceptionが発生する(string? assetCode) { // Arrange var orderItemId = 1L; @@ -22,7 +22,7 @@ public void Constructor_アセットコードがnullまたは空の文字列の } [Fact] - public void OrderItem_注文アイテムが初期化されていない場合例外() + public void OrderItem_注文アイテムが初期化されていない_InvalidOperationExceptionが発生する() { // Arrange string assetCode = "Asset Code"; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemTest.cs index 1f66289a8..7339f24ca 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderItemTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.ApplicationCore.Ordering; public class OrderItemTest { [Fact] - public void Constructor_注文されたカタログアイテムがnullの場合例外() + public void Constructor_注文されたカタログアイテムがnull_ArgumentNullExceptionが発生する() { // Arrange CatalogItemOrdered? itemOrdered = null; @@ -20,7 +20,7 @@ public void Constructor_注文されたカタログアイテムがnullの場合 } [Fact] - public void Order_注文情報が初期化されていない場合例外() + public void Order_注文情報が初期化されていない_InvalidOperationExceptionが発生する() { // Arrange CatalogItemOrdered itemOrdered = new CatalogItemOrdered(1L, "製品1", "A00000001"); @@ -37,7 +37,7 @@ public void Order_注文情報が初期化されていない場合例外() } [Fact] - public void AddAssets_注文アイテムアセットにnullを追加しようとすると例外() + public void AddAssets_注文アイテムアセットにnullを追加する_ArgumentNullExceptionが発生する() { // Arrange CatalogItemOrdered itemOrdered = new CatalogItemOrdered(1L, "製品1", "A00000001"); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs index 19883c0ae..772ba2691 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs @@ -30,7 +30,7 @@ public void Constructor_正しくインスタンス化できる() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void Constructor_購入者Idは必須(string? buyerId) + public void Constructor_購入者Idがnullまたは空の文字列_ArgumentExceptionが発生する(string? buyerId) { // Arrange var shipTo = CreateDefaultShipTo(); @@ -44,7 +44,7 @@ public void Constructor_購入者Idは必須(string? buyerId) } [Fact] - public void Constructor_住所は必須() + public void Constructor_住所がnull_ArgumentNullExceptionが発生する() { // Arrange var buyerId = Guid.NewGuid().ToString("D"); @@ -59,7 +59,7 @@ public void Constructor_住所は必須() [Theory] [MemberData(nameof(EmptyOrderItems))] - public void Constructor_注文アイテムは必須(List? emptyOrderItems) + public void Constructor_注文アイテムがnullまたは空のリスト_ArgumentExceptionが発生する(List? emptyOrderItems) { // Arrange var buyerId = Guid.NewGuid().ToString("D"); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/ShipToTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/ShipToTest.cs index e57f326f6..d1c0905d1 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/ShipToTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/ShipToTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.ApplicationCore.Ordering; public class ShipToTest { [Fact] - public void Constructor_宛名がnullの場合例外() + public void Constructor_宛名がnull_ArgumentNullExceptionが発生する() { // Arrange string? fullName = null; @@ -19,7 +19,7 @@ public void Constructor_宛名がnullの場合例外() } [Fact] - public void Constructor_住所がnullの場合例外() + public void Constructor_住所がnull_ArgumentNullExceptionが発生する() { // Arrange string fullName = "国会 太郎"; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs index fbff91d15..dae70ef9c 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.SystemCommon; public class BusinessErrorCollectionTest { [Fact] - public void AddOrMerge_nullを追加しようとすると例外() + public void AddOrMerge_nullを追加する_ArgumentNullExceptionが発生する() { // Arrange var errors = new BusinessErrorCollection(); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs index da799d7ab..5a175c4c7 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs @@ -89,7 +89,7 @@ public void AddErrorMessage_エラーメッセージを追加できる() } [Fact] - public void ToString_エラーコードが未設定の場合キーが空文字のJSON形式に変換される() + public void ToString_エラーコードが未設定_キーが空文字のJSON形式に変換される() { // Arrange var error = new BusinessError(); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessExceptionTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessExceptionTest.cs index f80e15ea0..62137f163 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessExceptionTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessExceptionTest.cs @@ -21,7 +21,7 @@ public void ToString_業務エラーのリストが文字列化される() } [Fact] - public void AddOrMergeError_nullを追加しようとすると例外() + public void AddOrMergeError_nullを追加する_ArgumentNullExceptionが発生する() { // Arrange BusinessError? businessError = null; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/ObjectExtensionsTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/ObjectExtensionsTest.cs index fd55b234d..1c27ed0ae 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/ObjectExtensionsTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/ObjectExtensionsTest.cs @@ -5,7 +5,7 @@ namespace Dressca.UnitTests.SystemCommon; public class ObjectExtensionsTest { [Fact] - public void ThrowIfNull_参照型の値がnullの場合例外() + public void ThrowIfNull_参照型の値がnull_ArgumentNullExceptionが発生する() { // Arrange object? obj = null; @@ -18,7 +18,7 @@ public void ThrowIfNull_参照型の値がnullの場合例外() } [Fact] - public void ThrowIfNull_Nullableな値型の値がnullの場合例外() + public void ThrowIfNull_Nullableな値型の値がnull_ArgumentNullExceptionが発生する() { // Arrange int? intValue = null; diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Assets/AssetExtensionsTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Assets/AssetExtensionsTest.cs index 507718bb2..8b993cb32 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Assets/AssetExtensionsTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Assets/AssetExtensionsTest.cs @@ -6,7 +6,7 @@ namespace Dressca.UnitTests.Web.Assets; public class AssetExtensionsTest { [Fact] - public void GetContentType_アセットがnullの場合例外() + public void GetContentType_アセットがnull_ArgumentNullExceptionが発生する() { // Arrange Asset? asset = null; @@ -19,7 +19,7 @@ public void GetContentType_アセットがnullの場合例外() } [Fact] - public void GetContentType_アセットタイプがPNGの場合() + public void GetContentType_アセットタイプがPNG_imagepngを取得できる() { // Arrange Asset asset = new Asset("asset-code", AssetTypes.Png); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs index 9212a4a71..361a79cca 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs @@ -6,7 +6,7 @@ namespace Dressca.UnitTests.Web.Baskets; public class HttpContextExtensionsTest { [Fact] - public void GetBuyerId_購入者IdがHttpContextに存在しない場合新たにGuid形式の購入者Idが発行される() + public void GetBuyerId_購入者IdがHttpContextに存在しない_新たにGuid形式の購入者Idが発行される() { // Arrange var items = new Dictionary(); @@ -21,7 +21,7 @@ public void GetBuyerId_購入者IdがHttpContextに存在しない場合新た } [Fact] - public void GetBuyerId_購入者Idが文字列型ではない場合新たにGuid形式の購入者Idが発行される() + public void GetBuyerId_購入者Idが文字列型ではない_新たにGuid形式の購入者Idが発行される() { // Arrange var items = new Dictionary @@ -42,7 +42,7 @@ public void GetBuyerId_購入者Idが文字列型ではない場合新たにGuid [InlineData(null)] [InlineData("")] [InlineData("not-guid-value")] - public void GetBuyerId_購入者IdがGuidの文字列ではない場合新たにGuid形式の購入者Idが発行される(string? itemValue) + public void GetBuyerId_購入者IdがGuidの文字列ではない_新たにGuid形式の購入者Idが発行される(string? itemValue) { // Arrange var items = new Dictionary @@ -60,7 +60,7 @@ public void GetBuyerId_購入者IdがGuidの文字列ではない場合新たに } [Fact] - public void GetBuyerId_購入者IdがGuidの文字列の場合設定されている値を取得できる() + public void GetBuyerId_購入者IdがGuidの文字列_設定されている値を取得できる() { // Arrange var buyerId = Guid.NewGuid().ToString(); From 6d8fd8899c313e0664c4e94c38f37781d87dd7fe Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:34:18 +0900 Subject: [PATCH 12/40] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=82=AF=E3=82=BF=E3=83=BC=E3=81=AE=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E3=81=AA=E3=83=86=E3=82=B9=E3=83=88=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=81=A7=E3=83=97=E3=83=A9=E3=82=A4=E3=83=9E=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationCore/Assets/AssetApplicationServiceTest.cs | 7 +------ .../Baskets/BasketApplicationServiceTest.cs | 7 +------ .../Catalog/CatalogApplicationServiceTest.cs | 7 +------ .../ApplicationCore/Catalog/CatalogDomainServiceTest.cs | 7 +------ .../Ordering/OrderApplicationServiceTest.cs | 7 +------ .../Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs | 7 +------ .../Web/Runtime/BusinessExceptionFilterTest.cs | 7 +------ 7 files changed, 7 insertions(+), 42 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs index 2b2730c4d..421459403 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Assets/AssetApplicationServiceTest.cs @@ -3,13 +3,8 @@ namespace Dressca.UnitTests.ApplicationCore.Assets; -public class AssetApplicationServiceTest : TestBase +public class AssetApplicationServiceTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public AssetApplicationServiceTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - [Fact] public void GetAssetStreamInfo_リポジトリに指定したアセットコードの情報が見つからない_AssetNotFoundExceptionが発生する() { diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs index 829f30fe4..e6fcadaf8 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs @@ -6,13 +6,8 @@ namespace Dressca.UnitTests.ApplicationCore.Baskets; /// /// 買い物かごアプリケーションサービスの単体テストです。 /// -public class BasketApplicationServiceTest : TestBase +public class BasketApplicationServiceTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public BasketApplicationServiceTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - private static CancellationToken AnyToken => It.IsAny(); [Theory] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs index f29944614..fe35f471c 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogApplicationServiceTest.cs @@ -7,13 +7,8 @@ namespace Dressca.UnitTests.ApplicationCore.Catalog; /// /// カタログアプリケーションサービスの単体テストです。 /// -public class CatalogApplicationServiceTest : TestBase +public class CatalogApplicationServiceTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public CatalogApplicationServiceTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - private static CancellationToken AnyToken => It.IsAny(); [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index e8fc8c12b..7c286892e 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -5,13 +5,8 @@ namespace Dressca.UnitTests.ApplicationCore.Catalog; -public class CatalogDomainServiceTest : TestBase +public class CatalogDomainServiceTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public CatalogDomainServiceTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - private static CancellationToken AnyToken => It.IsAny(); [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs index ab0015b0f..851e32c02 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderApplicationServiceTest.cs @@ -6,13 +6,8 @@ namespace Dressca.UnitTests.ApplicationCore.Ordering; -public class OrderApplicationServiceTest : TestBase +public class OrderApplicationServiceTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public OrderApplicationServiceTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - private static CancellationToken AnyToken => It.IsAny(); [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs index c32b3f010..4b6c3fb90 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs @@ -12,13 +12,8 @@ namespace Dressca.UnitTests.Web.Runtime; -public class BusinessExceptionDevelopmentFilterTest : TestBase +public class BusinessExceptionDevelopmentFilterTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public BusinessExceptionDevelopmentFilterTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - [Fact] public void OnException_業務エラーの情報がActionResultの値に設定される() { diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs index 33107753f..8e77937c0 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs @@ -13,13 +13,8 @@ namespace Dressca.UnitTests.Web.Runtime; -public class BusinessExceptionFilterTest : TestBase +public class BusinessExceptionFilterTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public BusinessExceptionFilterTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - [Fact] public void OnException_業務エラーの情報がActionResultの値に設定される() { From 2f9574c38b94e056739ccbc7d7940d377f532f02 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:35:15 +0900 Subject: [PATCH 13/40] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AAusing=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs index 8e77937c0..aa67a415e 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs @@ -1,6 +1,5 @@ using Dressca.SystemCommon; using Dressca.Web.Runtime; -using Maris.Logging.Testing.Xunit; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; From edb5592959507d2f74398167630028ee7ef06ae3 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:40:45 +0900 Subject: [PATCH 14/40] =?UTF-8?q?Dressca.UnitTests=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=AC=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E6=A4=9C=E8=A8=BC?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=A7=E8=A6=81=E7=B4=A0=E6=95=B0=E3=81=8C?= =?UTF-8?q?1=E3=81=AE=E3=82=82=E3=81=AE=E3=82=92=E6=A4=9C=E8=A8=BC?= =?UTF-8?q?=E3=81=99=E3=82=8B=E5=A0=B4=E5=90=88Assert.Single=E3=82=92?= =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationCore/Baskets/BasketTest.cs | 42 +++---------------- .../Catalog/CatalogDomainServiceTest.cs | 4 +- .../BusinessErrorCollectionTest.cs | 24 +++-------- .../SystemCommon/BusinessErrorTest.cs | 4 +- .../Web/Baskets/HttpContextExtensionsTest.cs | 18 ++------ .../BusinessExceptionDevelopmentFilterTest.cs | 13 ++---- .../Runtime/BusinessExceptionFilterTest.cs | 13 ++---- 7 files changed, 26 insertions(+), 92 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs index ca56fb5f6..debcd7561 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs @@ -66,12 +66,7 @@ public void AddItem_買い物かご内の商品の数量を加算しても買い basket.AddItem(1L, 1000, 9); // Assert - Assert.Collection( - basket.Items, - item => - { - Assert.Equal(1L, item.CatalogItemId); - }); + Assert.Single(basket.Items, item => item.CatalogItemId == 1L); } [Fact] @@ -85,13 +80,8 @@ public void AddItem_買い物かご内の商品の数量を加算できる() basket.AddItem(1L, 1000, 9); // Assert - Assert.Collection( - basket.Items, - item => - { - Assert.Equal(1L, item.CatalogItemId); + var item = Assert.Single(basket.Items, item => item.CatalogItemId == 1L); Assert.Equal(10, item.Quantity); - }); } [Theory] @@ -123,12 +113,7 @@ public void AddItem_買い物かご内の商品の数量を減算できる(int f basket.AddItem(1L, 1000, additionalQuantity); // Assert - Assert.Collection( - basket.Items, - item => - { - Assert.Equal(firstQuantity + additionalQuantity, item.Quantity); - }); + Assert.Single(basket.Items, item => item.Quantity == firstQuantity + additionalQuantity); } [Fact] @@ -155,13 +140,8 @@ public void RemoveEmptyItems_買い物かごに数量1のアイテムが1件存 basket.RemoveEmptyItems(); // Assert - Assert.Collection( - basket.Items, - item => - { - Assert.Equal(1L, item.CatalogItemId); + var item = Assert.Single(basket.Items, item => item.CatalogItemId == 1L); Assert.Equal(1, item.Quantity); - }); } [Fact] @@ -205,13 +185,8 @@ public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件_数 basket.RemoveEmptyItems(); // Assert - Assert.Collection( - basket.Items, - item => - { - Assert.Equal(2L, item.CatalogItemId); + var item = Assert.Single(basket.Items, item => item.CatalogItemId == 2L); Assert.Equal(1, item.Quantity); - }); } [Fact] @@ -254,13 +229,8 @@ public void RemoveEmptyItems_数量0の商品を買い物かごから削除し basket.RemoveEmptyItems(); // Assert - Assert.Collection( - basket.Items, - item => - { - Assert.Equal(2L, item.CatalogItemId); + var item = Assert.Single(basket.Items, item => item.CatalogItemId == 2L); Assert.Equal(1, item.Quantity); - }); } [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index 7c286892e..25e7606dd 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -58,9 +58,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 // Assert Assert.False(existsAll); - Assert.Collection( - items, - item => Assert.Equal(2L, item.Id)); + Assert.Single(items, item => item.Id == 2L); } [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs index dae70ef9c..8937ab585 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorCollectionTest.cs @@ -31,15 +31,8 @@ public void AddOrMerge_コレクションに追加していないエラーコー errors.AddOrMerge(newBusinessError); // Assert - Assert.Collection( - errors, - error => - { - Assert.Equal(errorCode, error.ErrorCode); - Assert.Collection( - error.ErrorMessages, - message => Assert.Equal(errorMessage, message)); - }); + var error = Assert.Single(errors, error => error.ErrorCode == errorCode); + Assert.Single(error.ErrorMessages, message => message == errorMessage); } [Fact] @@ -58,16 +51,11 @@ public void AddOrMerge_コレクションに追加済みのエラーコードの errors.AddOrMerge(businessError2); // Assert + var error = Assert.Single(errors, error => error.ErrorCode == errorCode); Assert.Collection( - errors, - error => - { - Assert.Equal(errorCode, error.ErrorCode); - Assert.Collection( - error.ErrorMessages, - message => Assert.Equal(errorMessage1, message), - message => Assert.Equal(errorMessage2, message)); - }); + error.ErrorMessages, + message => Assert.Equal(errorMessage1, message), + message => Assert.Equal(errorMessage2, message)); } [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs index 5a175c4c7..a7f238c15 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs @@ -66,9 +66,7 @@ public void AddErrorMessage_nullを追加すると空文字が追加される() error.AddErrorMessage(errorMessage); // Assert - Assert.Collection( - error.ErrorMessages, - errorMessage => Assert.Equal(string.Empty, errorMessage)); + Assert.Single(error.ErrorMessages, errorMessage => errorMessage == string.Empty); } [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs index 361a79cca..0b29ecfcd 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Baskets/HttpContextExtensionsTest.cs @@ -91,13 +91,8 @@ public void SetBuyerId_購入者Idを新たに追加できる() HttpContextExtensions.SetBuyerId(httpContextMock.Object, buyerId); // Assert - Assert.Collection( - items, - item => - { - Assert.Equal("Dressca-BuyerId", item.Key); - Assert.Equal(buyerId, item.Value); - }); + var item = Assert.Single(items, item => "Dressca-BuyerId".Equals(item.Key)); + Assert.Equal(buyerId, item.Value); } [Fact] @@ -116,12 +111,7 @@ public void SetBuyerId_購入者Idを上書きできる() HttpContextExtensions.SetBuyerId(httpContextMock.Object, buyerId); // Assert - Assert.Collection( - items, - item => - { - Assert.Equal("Dressca-BuyerId", item.Key); - Assert.Equal(buyerId, item.Value); - }); + var item = Assert.Single(items, item => "Dressca-BuyerId".Equals(item.Key)); + Assert.Equal(buyerId, item.Value); } } diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs index 4b6c3fb90..9ce6ea907 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionDevelopmentFilterTest.cs @@ -31,16 +31,11 @@ public void OnException_業務エラーの情報がActionResultの値に設定 // Assert var result = Assert.IsType(context.Result); var value = Assert.IsType(result.Value); + var error = Assert.Single(value.Errors, error => errorCode.Equals(error.Key)); Assert.Collection( - value.Errors, - error => - { - Assert.Equal(errorCode, error.Key); - Assert.Collection( - error.Value, - message => Assert.Equal(errorMessage1, message), - message => Assert.Equal(errorMessage2, message)); - }); + error.Value, + message => Assert.Equal(errorMessage1, message), + message => Assert.Equal(errorMessage2, message)); } [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs index aa67a415e..7437c09fb 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/Web/Runtime/BusinessExceptionFilterTest.cs @@ -31,16 +31,11 @@ public void OnException_業務エラーの情報がActionResultの値に設定 // Assert var result = Assert.IsType(context.Result); var value = Assert.IsType(result.Value); + var error = Assert.Single(value.Errors, error => errorCode.Equals(error.Key)); Assert.Collection( - value.Errors, - error => - { - Assert.Equal(errorCode, error.Key); - Assert.Collection( - error.Value, - message => Assert.Equal(errorMessage1, message), - message => Assert.Equal(errorMessage2, message)); - }); + error.Value, + message => Assert.Equal(errorMessage1, message), + message => Assert.Equal(errorMessage2, message)); } [Fact] From f02c7d93b339777600852a0c204f8fa1477999a9 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:43:14 +0900 Subject: [PATCH 15/40] =?UTF-8?q?Dressca.UnitTests=E3=81=AE=E9=85=8D?= =?UTF-8?q?=E5=88=97=E3=80=81=E3=83=AA=E3=82=B9=E3=83=88=E5=88=9D=E6=9C=9F?= =?UTF-8?q?=E5=8C=96=E5=87=A6=E7=90=86=E3=82=92=E7=B0=A1=E6=98=93=E6=A7=8B?= =?UTF-8?q?=E6=96=87=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationCore/Baskets/BasketTest.cs | 8 ++++---- .../Catalog/CatalogDomainServiceTest.cs | 10 +++++----- .../SystemCommon/BusinessErrorTest.cs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs index debcd7561..b6911f252 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketTest.cs @@ -81,7 +81,7 @@ public void AddItem_買い物かご内の商品の数量を加算できる() // Assert var item = Assert.Single(basket.Items, item => item.CatalogItemId == 1L); - Assert.Equal(10, item.Quantity); + Assert.Equal(10, item.Quantity); } [Theory] @@ -141,7 +141,7 @@ public void RemoveEmptyItems_買い物かごに数量1のアイテムが1件存 // Assert var item = Assert.Single(basket.Items, item => item.CatalogItemId == 1L); - Assert.Equal(1, item.Quantity); + Assert.Equal(1, item.Quantity); } [Fact] @@ -186,7 +186,7 @@ public void RemoveEmptyItems_買い物かごに数量0のアイテムが1件_数 // Assert var item = Assert.Single(basket.Items, item => item.CatalogItemId == 2L); - Assert.Equal(1, item.Quantity); + Assert.Equal(1, item.Quantity); } [Fact] @@ -230,7 +230,7 @@ public void RemoveEmptyItems_数量0の商品を買い物かごから削除し // Assert var item = Assert.Single(basket.Items, item => item.CatalogItemId == 2L); - Assert.Equal(1, item.Quantity); + Assert.Equal(1, item.Quantity); } [Fact] diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs index 25e7606dd..cf523891b 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Catalog/CatalogDomainServiceTest.cs @@ -27,7 +27,7 @@ public async Task ExistsAllAsync_カタログアイテムIdがすべて存在す var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act - var (existsAll, items) = await domainService.ExistsAllAsync(new[] { 1L, 2L }); + var (existsAll, items) = await domainService.ExistsAllAsync([1L, 2L]); // Assert Assert.True(existsAll); @@ -54,7 +54,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act - var (existsAll, items) = await domainService.ExistsAllAsync(new[] { 1L, 2L }); + var (existsAll, items) = await domainService.ExistsAllAsync([1L, 2L]); // Assert Assert.False(existsAll); @@ -78,7 +78,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが一部だけ存在 var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act - _ = await domainService.ExistsAllAsync(new[] { 1L, 2L }); + _ = await domainService.ExistsAllAsync([1L, 2L]); // Assert Assert.Equal(1, this.LogCollector.Count); @@ -102,7 +102,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが1件も存在し var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act - var (existsAll, items) = await domainService.ExistsAllAsync(new[] { 1L }); + var (existsAll, items) = await domainService.ExistsAllAsync([1L]); // Assert Assert.False(existsAll); @@ -123,7 +123,7 @@ public async Task ExistsAllAsync_カタログアイテムIdが1件も存在し var domainService = new CatalogDomainService(catalogRepositoryMock.Object, logger); // Act - _ = await domainService.ExistsAllAsync(new[] { 1L }); + _ = await domainService.ExistsAllAsync([1L]); // Assert Assert.Equal(1, this.LogCollector.Count); diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs index a7f238c15..46cb97eff 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/SystemCommon/BusinessErrorTest.cs @@ -29,7 +29,7 @@ public void Constructor_引数ありコンストラクターを使用すると { // Arrange string? errorCode = "ERR_CODE"; - string[] errorMessages = new[] { "ERR_MESSAGE1", "ERR_MESSAGE2" }; + string[] errorMessages = ["ERR_MESSAGE1", "ERR_MESSAGE2"]; // Act var error = new BusinessError(errorCode, errorMessages); @@ -43,7 +43,7 @@ public void Constructor_引数ありコンストラクターを使用すると { // Arrange string? errorCode = "ERR_CODE"; - string[] errorMessages = new[] { "ERR_MESSAGE1", "ERR_MESSAGE2" }; + string[] errorMessages = ["ERR_MESSAGE1", "ERR_MESSAGE2"]; // Act var error = new BusinessError(errorCode, errorMessages); @@ -73,7 +73,7 @@ public void AddErrorMessage_nullを追加すると空文字が追加される() public void AddErrorMessage_エラーメッセージを追加できる() { // Arrange - var error = new BusinessError("ERR_CODE", new[] { "ERR_MESSAGE1" }); + var error = new BusinessError("ERR_CODE", ["ERR_MESSAGE1"]); string? errorMessage = "ERR_MESSAGE2"; // Act From ee407d4d7da717c880eb67711044d2fe20a7f7b6 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:43:57 +0900 Subject: [PATCH 16/40] =?UTF-8?q?Dressca.UnitTests=E3=81=A7=E8=A6=81?= =?UTF-8?q?=E7=B4=A0=E6=95=B0=E3=81=8C0=E3=81=AE=E6=A4=9C=E8=A8=BC?= =?UTF-8?q?=E3=82=92Count=E3=83=97=E3=83=AD=E3=83=91=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=81=A7=E5=AE=9F=E6=96=BD=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationCore/Baskets/BasketApplicationServiceTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs index e6fcadaf8..01e9b67c3 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Baskets/BasketApplicationServiceTest.cs @@ -233,7 +233,7 @@ public async Task AddItemToBasketAsync_買い物かごへの商品追加処理 // Assert repoMock.Verify( - r => r.UpdateAsync(It.Is(b => !b.Items.Any()), AnyToken), + r => r.UpdateAsync(It.Is(b => b.Items.Count == 0), AnyToken), Times.Once); } From 798bbac5608900d85f5d1c4fdc78051011d3a752 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:44:40 +0900 Subject: [PATCH 17/40] =?UTF-8?q?null=E3=82=92=E8=A8=B1=E5=AE=B9=E3=81=99?= =?UTF-8?q?=E3=82=8B=E7=AE=87=E6=89=80=E3=81=A7Null=E8=A8=B1=E5=AE=B9?= =?UTF-8?q?=E5=8F=82=E7=85=A7=E5=9E=8B=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs index 772ba2691..0eb3eca9b 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs @@ -4,9 +4,9 @@ namespace Dressca.UnitTests.ApplicationCore.Ordering; public class OrderTest { - public static TheoryData> EmptyOrderItems => new() + public static TheoryData?> EmptyOrderItems => new() { - null!, + null, new List(), }; From e6c870416e616e84c751d38d2f23a3e7e49216ba Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:45:11 +0900 Subject: [PATCH 18/40] =?UTF-8?q?=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E5=88=9D=E6=9C=9F=E5=8C=96=E3=81=AE=E7=B0=A1?= =?UTF-8?q?=E6=98=93=E6=A7=8B=E6=96=87=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs index 0eb3eca9b..114b7c3a7 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.UnitTests/ApplicationCore/Ordering/OrderTest.cs @@ -165,8 +165,8 @@ private static List CreateDefaultOrderItems() var items = new List() { - new OrderItem(new CatalogItemOrdered(1, productName1, productCode1), 1000m, 1), - new OrderItem(new CatalogItemOrdered(2, productName2, productCode2), 1500m, 2), + new(new CatalogItemOrdered(1, productName1, productCode1), 1000m, 1), + new(new CatalogItemOrdered(2, productName2, productCode2), 1500m, 2), }; return items; From 10027b1b2d74d75df2db5e7f66e9f7246b8d1860 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:36:05 +0900 Subject: [PATCH 19/40] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=A4=E3=83=9E?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=83=BC=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dressca.IntegrationTest/DatabaseHealthCheckTest.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index 53ba2a1c6..820e80689 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -2,14 +2,10 @@ namespace Dressca.IntegrationTest; -public class DatabaseHealthCheckTest : IClassFixture> +public class DatabaseHealthCheckTest(IntegrationTestWebApplicationFactory factory) + : IClassFixture> { - private readonly IntegrationTestWebApplicationFactory factory; - - public DatabaseHealthCheckTest(IntegrationTestWebApplicationFactory factory) - { - this.factory = factory; - } + private readonly IntegrationTestWebApplicationFactory factory = factory; [Fact] public async Task DatabaseConnectionTest() From d54ad5b503ca74081005e0ecd4a8a11f7ed2e6f6 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:38:56 +0900 Subject: [PATCH 20/40] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E5=90=8D=E3=81=AB=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E4=BB=95=E6=A7=98=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs index 820e80689..0fcf1c80f 100644 --- a/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs +++ b/samples/Dressca/dressca-backend/tests/Dressca.IntegrationTest/DatabaseHealthCheckTest.cs @@ -8,7 +8,7 @@ public class DatabaseHealthCheckTest(IntegrationTestWebApplicationFactory factory = factory; [Fact] - public async Task DatabaseConnectionTest() + public async Task Get_ApiHealth_DBまで含めたヘルスチェックが正常に動作_Healthyを返す() { // Arrange var client = this.factory.CreateClient(); From 68fb099312b73c4d907c70bda3416a1289dc7573 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:51:18 +0900 Subject: [PATCH 21/40] =?UTF-8?q?default=E3=81=AE=E7=9F=AD=E7=B8=AE?= =?UTF-8?q?=E6=A7=8B=E6=96=87=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Maris.Logging.Testing.Tests/Xunit/TestLoggerManagerTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerManagerTest.cs b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerManagerTest.cs index 8de0868cf..ade0217a9 100644 --- a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerManagerTest.cs +++ b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerManagerTest.cs @@ -126,7 +126,7 @@ public void LogCollector_CanGetLoggedRecords_Double() secondRecord => { Assert.Equal(LogLevel.Trace, secondRecord.Level); - Assert.Equal(default(EventId), secondRecord.Id); + Assert.Equal(default, secondRecord.Id); Assert.Null(secondRecord.Exception); Assert.Equal(message2, secondRecord.Message); }); From b5f29db382a2c89cdb6d38337895e37a29cd43b0 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:51:51 +0900 Subject: [PATCH 22/40] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E5=90=8D=E3=81=AB=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E4=BB=95=E6=A7=98=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Xunit/TestLoggerServiceCollectionExtensionsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerServiceCollectionExtensionsTest.cs b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerServiceCollectionExtensionsTest.cs index 294bcdcb5..cf1662cb3 100644 --- a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerServiceCollectionExtensionsTest.cs +++ b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/TestLoggerServiceCollectionExtensionsTest.cs @@ -38,7 +38,7 @@ public void AddTestLogging_LoggerManagerIsNull_ThrowsArgumentNullException() } [Fact] - public void AddTestLogging_ValidInputs_AddsTestLoggingAndTwoLoggerProviders() + public void AddTestLogging_ValidInputs_AddsLoggerAndTwoLoggerProviders() { // Arrange var services = new ServiceCollection(); From bc2b8be5bdcc39b3d0db0f6bbb66febf4df92b22 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:53:19 +0900 Subject: [PATCH 23/40] =?UTF-8?q?MemberDataAttribute=E3=81=AE=E5=AF=BE?= =?UTF-8?q?=E8=B1=A1=E3=83=87=E3=83=BC=E3=82=BF=E3=81=ABTheoryData?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Xunit/XunitLoggerTest.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs index a73272ee7..0ea98e8e8 100644 --- a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs +++ b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs @@ -1,4 +1,5 @@ -using Maris.Logging.Testing.Xunit; +using System.Net.Http.Headers; +using Maris.Logging.Testing.Xunit; using Microsoft.Extensions.Logging; using Xunit.Abstractions; @@ -6,8 +7,19 @@ namespace Maris.Logging.Testing.Tests.Xunit; public class XunitLoggerTest { - public static IEnumerable LogLevels - => Enum.GetValues().Select(logLevel => new object[] { logLevel }); + public static TheoryData LogLevels + { + get + { + var data = new TheoryData(); + foreach (var logLevel in Enum.GetValues()) + { + data.Add(logLevel); + } + + return data; + } + } [Fact] public void Constructor_ThrowsException_WhenTestOutputHelperIsNull() From e0550b7b25ff782156ad158bf974cf02dcd51df5 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:53:57 +0900 Subject: [PATCH 24/40] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AAusing=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs index 0ea98e8e8..e1853c34e 100644 --- a/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs +++ b/samples/Dressca/dressca-backend/tests/Maris.Logging.Testing.Tests/Xunit/XunitLoggerTest.cs @@ -1,5 +1,4 @@ -using System.Net.Http.Headers; -using Maris.Logging.Testing.Xunit; +using Maris.Logging.Testing.Xunit; using Microsoft.Extensions.Logging; using Xunit.Abstractions; From d1006e7ab46b16f13bb51f5efaa95156ceb899f8 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 22:39:32 +0900 Subject: [PATCH 25/40] =?UTF-8?q?.gitignore=E3=81=AB*.lutconfig=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/ConsoleAppWithDI/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/ConsoleAppWithDI/.gitignore b/samples/ConsoleAppWithDI/.gitignore index 1ee53850b..a6a014765 100644 --- a/samples/ConsoleAppWithDI/.gitignore +++ b/samples/ConsoleAppWithDI/.gitignore @@ -9,6 +9,7 @@ *.user *.userosscache *.sln.docstates +*.lutconfig # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs From 514e7fbea429b6fa8c3873da4e568c655e57bad2 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Thu, 8 Feb 2024 22:47:49 +0900 Subject: [PATCH 26/40] =?UTF-8?q?IDE0039=E3=82=92=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=B3=E3=83=BC=E3=83=89=E3=81=A7=E3=81=AF=E7=84=A1?= =?UTF-8?q?=E8=A6=96=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/ConsoleAppWithDI/solution/tests/.editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/ConsoleAppWithDI/solution/tests/.editorconfig b/samples/ConsoleAppWithDI/solution/tests/.editorconfig index c5142fde3..b8668a97c 100644 --- a/samples/ConsoleAppWithDI/solution/tests/.editorconfig +++ b/samples/ConsoleAppWithDI/solution/tests/.editorconfig @@ -1,5 +1,6 @@ [*.cs] # Wrapping preferences +dotnet_diagnostic.IDE0039.severity=none dotnet_diagnostic.SA0001.severity=none dotnet_diagnostic.SA1123.severity=none dotnet_diagnostic.SA1600.severity=none From 7e021bcb4a863ddfeff43b4ae07982c36f5544de Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:01:02 +0900 Subject: [PATCH 27/40] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE=E5=90=8D=E5=89=8D=E3=81=A7?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E4=BB=95=E6=A7=98=E3=82=92=E8=A1=A8?= =?UTF-8?q?=E7=8F=BE=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/AsyncCommandTest.cs | 8 +++---- .../Core/CommandAttributeTest.cs | 4 ++-- .../Core/CommandBaseTest.cs | 16 +++++++------- .../Core/CommandExecutorTest.cs | 22 +++++++++---------- .../Core/CommandTypeExtensionsTest.cs | 6 ++--- .../Core/ConsoleAppContextTest.cs | 4 ++-- .../Core/InvalidParameterExceptionTest.cs | 10 ++++----- .../Core/SyncCommandTest.cs | 8 +++---- .../CommandParameterTypeCollectionTest.cs | 12 +++++----- .../Hosting/ConsoleAppHostedServiceTest.cs | 16 +++++++------- .../Hosting/ConsoleAppSettingsTest.cs | 4 ++-- .../Hosting/DefaultCommandManagerTest.cs | 10 ++++----- .../ServiceCollectionExtensionsTest.cs | 12 +++++----- 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs index c36b38f8b..d088550ec 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs @@ -26,7 +26,7 @@ public void Parameter_ConsoleAppContextに設定したパラメーターを取 } [Fact] - public void ValidateAllParameterを呼び出すとValidateParameterメソッドが指定したパラメーターを伴って呼び出される() + public void ValidateAllParameter_ValidateParameterメソッドがコンテキストに指定したパラメーターを伴って1回呼び出される() { // Arrange var parameter = new CommandParameter(); @@ -44,7 +44,7 @@ public void ValidateAllParameterを呼び出すとValidateParameterメソッド } [Fact] - public void IAsyncCommandのExecuteAsyncを呼び出すとExecuteAsyncメソッドが指定したパラメーターとキャンセルトークンを伴って呼び出される() + public void IAsyncCommandのExecuteAsync_ExecuteAsyncメソッドがコンテキストに指定したパラメーターとキャンセルトークンを伴って1回呼び出される() { // Arrange var parameter = new CommandParameter(); @@ -64,7 +64,7 @@ public void IAsyncCommandのExecuteAsyncを呼び出すとExecuteAsyncメソッ } [Fact] - public void パラメーターの型にインターフェースを使用できる() + public void Initialize_パラメーターの型にインターフェースを使用できる() { // Arrange var parameter = new ParameterWithInterface(); @@ -78,7 +78,7 @@ public void パラメーターの型にインターフェースを使用でき } [Fact] - public void パラメーターの型とコンテキストのパラメーター型が一致しない場合は例外() + public void Initialize_パラメーターの型とコンテキストのパラメーター型が一致しない_InvalidOperationExceptionが発生する() { // Arrange var parameter = new ParameterWithInterface(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandAttributeTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandAttributeTest.cs index ffa2728c9..bfa279345 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandAttributeTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandAttributeTest.cs @@ -5,7 +5,7 @@ namespace Maris.ConsoleApp.UnitTests.Core; public class CommandAttributeTest { [Fact] - public void Constructor_コマンドの型がnullの場合は例外() + public void Constructor_コマンドの型がnull_ArgumentNullExceptionが発生する() { // Arrange string name = "command"; @@ -19,7 +19,7 @@ public void Constructor_コマンドの型がnullの場合は例外() } [Fact] - public void Constructor_コマンドの型がコマンドの定義を満たしていない場合は例外() + public void Constructor_コマンドの型がコマンドの定義を満たしていない_ArgumentExceptionが発生する() { // Arrange string name = "command"; diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs index f17f4f587..1cd6a86e3 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs @@ -37,7 +37,7 @@ public void CommandName_初期化時に指定したコマンド名を取得で } [Fact] - public void Context_初期値のまま取得すると例外() + public void Context_初期値のまま取得する_InvalidOperationExceptionが発生する() { // Arrange var command = new CommandImpl(); @@ -68,7 +68,7 @@ public void Context_初期化時に指定したコンテキストを取得でき } [Fact] - public void Initialize_nullで初期化すると例外() + public void Initialize_nullで初期化する_ArgumentNullExceptionが発生する() { // Arrange var command = new CommandImpl(); @@ -82,7 +82,7 @@ public void Initialize_nullで初期化すると例外() } [Fact] - public void ValidateAllParameter_入力パラメータのクラスにプロパティが定義されていない() + public void ValidateAllParameter_入力パラメータのクラスにプロパティが定義されていない_例外が発生しない() { // Arrange var command = new CommandImpl(); @@ -96,7 +96,7 @@ public void ValidateAllParameter_入力パラメータのクラスにプロパ } [Fact] - public void ValidateAllParameter_入力パラメータのクラスにプロパティがあるが検証属性が定義されていない() + public void ValidateAllParameter_入力パラメータのクラスにプロパティがあるが検証属性が定義されていない_例外が発生しない() { // Arrange var command = new CommandImpl(); @@ -112,7 +112,7 @@ public void ValidateAllParameter_入力パラメータのクラスにプロパ [Theory] [InlineData("", 0)] [InlineData("1234567890", 5)] - public void ValidateAllParameter_入力パラメータのクラスに検証属性を定義したプロパティがあり検証に成功する値が設定されている(string param1, int param2) + public void ValidateAllParameter_入力パラメータのクラスに検証属性を定義したプロパティがあり検証に成功する値が設定されている_例外が発生しない(string param1, int param2) { // Arrange var command = new CommandImpl(); @@ -131,7 +131,7 @@ public void ValidateAllParameter_入力パラメータのクラスに検証属 } [Fact] - public void ValidateAllParameter_入力パラメータのクラスに検証属性を定義したプロパティがあり一部検証に失敗する値が設定されている() + public void ValidateAllParameter_入力パラメータのクラスに検証属性を定義したプロパティがあり一部検証に失敗する値が設定されている_検証失敗メッセージを伴うInvalidParameterExceptionが発生する() { // Arrange var command = new CommandImpl(); @@ -159,7 +159,7 @@ public void ValidateAllParameter_入力パラメータのクラスに検証属 } [Fact] - public void ValidateAllParameter_入力パラメータのクラスに検証属性を定義したプロパティがあり複数検証に失敗する値が設定されている() + public void ValidateAllParameter_入力パラメータのクラスに検証属性を定義したプロパティがあり複数検証に失敗する値が設定されている_検証失敗メッセージを伴うInvalidParameterExceptionが発生する() { // Arrange var command = new CommandImpl(); @@ -188,7 +188,7 @@ public void ValidateAllParameter_入力パラメータのクラスに検証属 } [Fact] - public void ValidateAllParameter_コマンドクラスのロジック内でパラメーターの入力値検証エラーがあった() + public void ValidateAllParameter_コマンドクラスのロジック内でパラメーターの入力値検証エラーがあった_InvalidParameterExceptionが発生する() { // Arrange var command = new ValidationErrorCommand(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs index 49ff9fbce..10aa5280d 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs @@ -8,7 +8,7 @@ namespace Maris.ConsoleApp.UnitTests.Core; public class CommandExecutorTest { [Fact] - public void Constructor_managerがnullの場合は例外() + public void Constructor_managerがnull_ArgumentNullExceptionが発生する() { // Arrange ICommandManager? manager = null; @@ -22,7 +22,7 @@ public void Constructor_managerがnullの場合は例外() } [Fact] - public void Constructor_ロガーがnullの場合は例外() + public void Constructor_ロガーがnullの場合_ArgumentNullExceptionが発生する() { // Arrange var managerMock = new Mock(); @@ -36,7 +36,7 @@ public void Constructor_ロガーがnullの場合は例外() } [Fact] - public void Constructor_managerを使ってコマンドが生成される() + public void Constructor_ICommandManagerのCreateCommandが1回呼び出される() { // Arrange var managerMock = new Mock(); @@ -53,7 +53,7 @@ public void Constructor_managerを使ってコマンドが生成される() } [Fact] - public void Constructor_マネージャーがコマンドを作成できなかった場合は例外() + public void Constructor_ICommandManagerがコマンドを作成できない_ArgumentExceptionが発生する() { // Arrange var managerMock = new Mock(); @@ -74,7 +74,7 @@ public void Constructor_マネージャーがコマンドを作成できなか [InlineData(null)] [InlineData("")] [InlineData("dummy-command")] - public void CommandName_マネージャーで生成したコマンドオブジェクトの名前を取得できる(string? commandName) + public void CommandName_ICommandManagerで生成したコマンドオブジェクトの名前を取得できる(string? commandName) { // Arrange var managerMock = new Mock(); @@ -93,7 +93,7 @@ public void CommandName_マネージャーで生成したコマンドオブジ } [Fact] - public async Task ExecuteCommandAsync_パラメーターの入力検証に失敗した場合は例外() + public async Task ExecuteCommandAsync_パラメーターの入力検証に失敗した_InvalidParameterExceptionが発生する() { // Arrange var commandAttribute = new CommandAttribute("sync-command", typeof(SyncCommandImpl)); @@ -120,7 +120,7 @@ public async Task ExecuteCommandAsync_パラメーターの入力検証に失敗 } [Fact] - public async Task ExecuteCommandAsync_パラメーターのカスタム入力検証に失敗した場合は例外() + public async Task ExecuteCommandAsync_パラメーターのカスタム入力検証に失敗した_InvalidParameterExceptionが発生する() { // Arrange var parameter = new ValidatableParameter(); @@ -146,7 +146,7 @@ public async Task ExecuteCommandAsync_パラメーターのカスタム入力検 } [Fact] - public async Task ExecuteCommandAsync_コマンド内のカスタム入力値検証に失敗した場合は例外() + public async Task ExecuteCommandAsync_コマンド内のカスタム入力値検証に失敗した_InvalidParameterExceptionが発生する() { // Arrange var commandAttribute = new CommandAttribute("sync-command", typeof(SyncCommandImpl)); @@ -182,7 +182,7 @@ public async Task ExecuteCommandAsync_コマンド内のカスタム入力値検 } [Fact] - public async Task ExecuteCommandAsync_SyncCommandの派生コマンドを実行可能() + public async Task ExecuteCommandAsync_SyncCommandの派生コマンドを実行可能_コマンドの戻り値を取得できる() { // Arrange var commandAttribute = new CommandAttribute("sync-command", typeof(SyncCommandImpl)); @@ -236,7 +236,7 @@ public async Task ExecuteCommandAsync_SyncCommandの派生コマンドにパラ } [Fact] - public async Task ExecuteCommandAsync_AsyncCommandの派生コマンドを実行可能() + public async Task ExecuteCommandAsync_AsyncCommandの派生コマンドを実行可能_コマンドの戻り値を取得できる() { // Arrange var commandAttribute = new CommandAttribute("async-command", typeof(AsyncCommandImpl)); @@ -260,7 +260,7 @@ public async Task ExecuteCommandAsync_AsyncCommandの派生コマンドを実行 } [Fact] - public async Task ExecuteCommandAsync_AsyncCommandの派生コマンドにパラメーターとキャンセルトークンが引き渡される() + public async Task ExecuteCommandAsync_AsyncCommandの派生コマンドのExecuteAsyncがパラメーターとキャンセルトークンを伴い1回呼び出される() { // Arrange var commandAttribute = new CommandAttribute("async-command", typeof(AsyncCommand)); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandTypeExtensionsTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandTypeExtensionsTest.cs index 68eab7bf4..da85d9994 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandTypeExtensionsTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandTypeExtensionsTest.cs @@ -5,7 +5,7 @@ namespace Maris.ConsoleApp.UnitTests.Core; public class CommandTypeExtensionsTest { [Fact] - public void IsCommandType_コマンドとは無関係の型を指定するとfalseを取得する() + public void IsCommandType_コマンドとは無関係の型を指定_false() { // Arrange Type type = typeof(DateTime); @@ -18,7 +18,7 @@ public void IsCommandType_コマンドとは無関係の型を指定するとfal } [Fact] - public void IsCommandType_CommandBaseだけを継承した型を指定するとfalseを取得する() + public void IsCommandType_CommandBaseだけを継承した型を指定_false() { // Arrange Type type = typeof(OnlyCommandBaseImpl); @@ -33,7 +33,7 @@ public void IsCommandType_CommandBaseだけを継承した型を指定するとf [Theory] [InlineData(typeof(SyncCommandImpl))] [InlineData(typeof(AsyncCommandImpl))] - public void IsCommandType_SyncCommandまたはAsyncCommandを継承した型を指定するとtrueを取得する(Type t) + public void IsCommandType_SyncCommandまたはAsyncCommandを継承した型を指定_true(Type t) { // Arrange Type type = t; diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/ConsoleAppContextTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/ConsoleAppContextTest.cs index 7cd89f008..3848e12ea 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/ConsoleAppContextTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/ConsoleAppContextTest.cs @@ -5,7 +5,7 @@ namespace Maris.ConsoleApp.UnitTests.Core; public class ConsoleAppContextTest { [Fact] - public void Constructor_パラメーターがnullの場合は例外() + public void Constructor_パラメーターがnull_ArgumentNullExceptionが発生する() { // Arrange object? parameter = null; @@ -18,7 +18,7 @@ public void Constructor_パラメーターがnullの場合は例外() } [Fact] - public void Constructor_パラメーターにCommandAttributeがついていない場合は例外() + public void Constructor_パラメーターにCommandAttributeがついていない_ArgumentExceptionが発生する() { // Arrange object parameter = new NoCommandAttributeParameter(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs index 803def5f5..e9ff841e9 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs @@ -6,7 +6,7 @@ namespace Maris.ConsoleApp.UnitTests.Core; public class InvalidParameterExceptionTest { [Fact] - public void Message_メッセージの既定値の確認() + public void Message_メッセージの既定値_コマンドのパラメーターに入力エラーがあります() { // Arrange var ex = new InvalidParameterException(); @@ -19,7 +19,7 @@ public void Message_メッセージの既定値の確認() } [Fact] - public void Message_検証結果が1件登録されている場合() + public void Message_検証結果が1件登録されている_メンバー名とエラーメッセージが含まれている() { // Arrange var errorMessage = "error message"; @@ -38,7 +38,7 @@ public void Message_検証結果が1件登録されている場合() } [Fact] - public void Message_検証結果が2件登録されている場合() + public void Message_検証結果が2件登録されている場合_メンバー名とエラーメッセージが含まれている() { // Arrange var errorMessage1 = "error message1"; @@ -60,7 +60,7 @@ public void Message_検証結果が2件登録されている場合() } [Fact] - public void ValidationResults_検証結果のリストを指定しない場合は空のリストを取得できる() + public void ValidationResults_検証結果のリストを指定しない_空のリスト() { // Arrange var ex = new InvalidParameterException(); @@ -73,7 +73,7 @@ public void ValidationResults_検証結果のリストを指定しない場合 } [Fact] - public void ValidationResults_検証結果のリストを指定した場合はそれを取得できる() + public void ValidationResults_検証結果のリストを指定_指定したリストを取得できる() { // Arrange string errorMessage1 = "error message1"; diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/SyncCommandTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/SyncCommandTest.cs index ac99f2e25..6509d495b 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/SyncCommandTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/SyncCommandTest.cs @@ -26,7 +26,7 @@ public void Parameter_ConsoleAppContextに設定したパラメーターを取 } [Fact] - public void ValidateAllParameterを呼び出すとValidateParameterメソッドが指定したパラメーターを伴って呼び出される() + public void ValidateAllParameter_ValidateParameterメソッドがコンテキストに指定したパラメーターを伴って1回呼び出される() { // Arrange var parameter = new CommandParameter(); @@ -44,7 +44,7 @@ public void ValidateAllParameterを呼び出すとValidateParameterメソッド } [Fact] - public void ISyncCommandのExecuteを呼び出すとExecuteメソッドが指定したパラメーターを伴って呼び出される() + public void ISyncCommandのExecute_Executeメソッドがコンテキストに指定したパラメーターを伴って1回呼び出される() { // Arrange var parameter = new CommandParameter(); @@ -63,7 +63,7 @@ public void ISyncCommandのExecuteを呼び出すとExecuteメソッドが指定 } [Fact] - public void パラメーターの型にインターフェースを使用できる() + public void Initialize_パラメーターの型にインターフェースを使用できる() { // Arrange var parameter = new ParameterWithInterface(); @@ -77,7 +77,7 @@ public void パラメーターの型にインターフェースを使用でき } [Fact] - public void パラメーターの型とコンテキストのパラメーター型が一致しない場合は例外() + public void Initialize_パラメーターの型とコンテキストのパラメーター型が一致しない_InvalidOperationExceptionが発生する() { // Arrange var parameter = new ParameterWithInterface(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs index 370b27e6d..a14d071bc 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs @@ -26,7 +26,7 @@ public void InitializeFromAllAssemblies_現在のアプリケーションドメ } [Fact] - public void GetEnumerator_要素を追加せずに取得すると空の列挙子を取得できる() + public void GetEnumerator_要素を追加せずに取得する_空の列挙子() { // Arrange var collection = new CommandParameterTypeCollection(); @@ -39,7 +39,7 @@ public void GetEnumerator_要素を追加せずに取得すると空の列挙子 } [Fact] - public void クラスの定義されていないアセンブリを読み込んでもパラメーターの型は登録されない() + public void AddCommandParameterTypeFrom_クラスの定義されていないアセンブリを読み込む_パラメーターの型は登録されない() { // Arrange var collection = new CommandParameterTypeCollection(); @@ -53,7 +53,7 @@ public void クラスの定義されていないアセンブリを読み込ん } [Fact] - public void パラメーターではないクラスだけが定義されたアセンブリを読み込んでもパラメーターの型は登録されない() + public void AddCommandParameterTypeFrom_パラメーターではないクラスだけが定義されたアセンブリを読み込む_パラメーターの型は登録されない() { // Arrange var collection = new CommandParameterTypeCollection(); @@ -73,7 +73,7 @@ public void パラメーターではないクラスだけが定義されたア } [Fact] - public void アセンブリからパラメーターの型だけが登録される() + public void AddCommandParameterTypeFrom_パラメーターを含むクラスが定義されたアセンブリを読み込む_アセンブリからパラメーターの型だけが登録される() { // Arrange var collection = new CommandParameterTypeCollection(); @@ -98,7 +98,7 @@ public void アセンブリからパラメーターの型だけが登録され } [Fact] - public void 同じ名前のコマンドがあると登録エラーになる() + public void AddCommandParameterTypeFrom_同じ名前のコマンドがある_ArgumentExceptionが発生する() { // Arrange var collection = new CommandParameterTypeCollection(); @@ -119,7 +119,7 @@ public void 同じ名前のコマンドがあると登録エラーになる() } [Fact] - public void 読み込んだアセンブリのリストを取得できる() + public void LoadedAssemblies_読み込んだアセンブリのリストを取得できる() { // Arrange var collection = new CommandParameterTypeCollection(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs index 65530b9b9..0c15bda4c 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs @@ -42,7 +42,7 @@ public static IEnumerable GetContextsAndCommands() } [Fact] - public void Constructor_lifetimeがnullの場合は例外() + public void Constructor_lifetimeがnull_ArgumentNullExceptionが発生する() { // Arrange IHostApplicationLifetime? lifetime = null; @@ -61,7 +61,7 @@ public void Constructor_lifetimeがnullの場合は例外() } [Fact] - public void Constructor_settingsがnullの場合は例外() + public void Constructor_settingsがnull_ArgumentNullExceptionが発生する() { // Arrange var lifetime = Mock.Of(); @@ -80,7 +80,7 @@ public void Constructor_settingsがnullの場合は例外() } [Fact] - public void Constructor_executorがnullの場合は例外() + public void Constructor_executorがnull_ArgumentNullExceptionが発生する() { // Arrange var lifetime = Mock.Of(); @@ -96,7 +96,7 @@ public void Constructor_executorがnullの場合は例外() } [Fact] - public void Constructor_loggerがnullの場合は例外() + public void Constructor_loggerがnull_ArgumentNullExceptionが発生する() { // Arrange var lifetime = Mock.Of(); @@ -115,7 +115,7 @@ public void Constructor_loggerがnullの場合は例外() } [Fact] - public async Task StartAsync_コマンドが正常に完了するとコマンドから返却した終了コードが設定される() + public async Task StartAsync_コマンドが正常に完了する_コマンドから返却した終了コードが設定される() { // Arrange var lifetime = Mock.Of(); @@ -144,7 +144,7 @@ public async Task StartAsync_コマンドが正常に完了するとコマンド } [Fact] - public async Task StartAsync_コマンドの入力値エラーがあると設定の入力値検証エラーの終了コードが設定される() + public async Task StartAsync_コマンドの入力値エラーがある_入力値検証エラーの終了コードが設定される() { // Arrange var lifetime = Mock.Of(); @@ -173,7 +173,7 @@ public async Task StartAsync_コマンドの入力値エラーがあると設定 } [Fact] - public async Task StartAsync_コマンドの実行時に例外が発生すると設定のエラーの既定の終了コードが設定される() + public async Task StartAsync_コマンドの実行時に例外が発生する_既定のエラー終了コードが設定される() { // Arrange var lifetime = Mock.Of(); @@ -203,7 +203,7 @@ public async Task StartAsync_コマンドの実行時に例外が発生すると [Theory] [MemberData(nameof(GetContextsAndCommands))] - public async Task StartAsync_コマンドが完了するとIHostApplicationLifetimeのStopApplicationが呼び出される(ConsoleAppContext context, CommandBase command) + public async Task StartAsync_コマンドが完了_IHostApplicationLifetimeのStopApplicationが1回呼び出される(ConsoleAppContext context, CommandBase command) { // Arrange var lifetimeMock = new Mock(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppSettingsTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppSettingsTest.cs index ffbd81e22..5e32dd2ac 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppSettingsTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppSettingsTest.cs @@ -5,7 +5,7 @@ namespace Maris.ConsoleApp.UnitTests.Hosting; public class ConsoleAppSettingsTest { [Fact] - public void DefaultErrorExitCode_既定値の確認() + public void DefaultErrorExitCode_intの最大値() { // Arrange var settings = new ConsoleAppSettings(); @@ -18,7 +18,7 @@ public void DefaultErrorExitCode_既定値の確認() } [Fact] - public void DefaultValidationErrorExitCode_既定値の確認() + public void DefaultValidationErrorExitCode_intの最小値() { // Arrange var settings = new ConsoleAppSettings(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs index 7a62f3a57..c7b573aa0 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs @@ -6,7 +6,7 @@ namespace Maris.ConsoleApp.UnitTests.Hosting; public class DefaultCommandManagerTest { [Fact] - public void Constructor_ConsoleAppContextがnullの場合は例外() + public void Constructor_ConsoleAppContextがnull_ArgumentNullExceptionが発生する() { // Arrange ConsoleAppContext? context = null; @@ -20,7 +20,7 @@ public void Constructor_ConsoleAppContextがnullの場合は例外() } [Fact] - public void Constructor_IServiceProviderがnullの場合は例外() + public void Constructor_IServiceProviderがnull_ArgumentNullExceptionが発生する() { // Arrange var parameter = new TestParameter(); @@ -35,7 +35,7 @@ public void Constructor_IServiceProviderがnullの場合は例外() } [Fact] - public void マネージャーに設定したコンテキストの情報が初期化処理を通してコマンドにも設定される() + public void CreateCommand_マネージャーに設定したコンテキストの情報がコマンドにも設定される() { // Arrange var provider = Mock.Of(); @@ -51,7 +51,7 @@ public void マネージャーに設定したコンテキストの情報が初 } [Fact] - public void ReleaseCommandを呼び出すとスコープがクローズされる() + public void ReleaseCommand_スコープがクローズされる() { // Arrange var provider = Mock.Of(); @@ -67,7 +67,7 @@ public void ReleaseCommandを呼び出すとスコープがクローズされる } [Fact] - public void ReleaseCommandを複数回呼び出しても例外にならずスコープはクローズされる() + public void ReleaseCommand_複数回呼び出しても例外にならずスコープはクローズされる() { // Arrange var provider = Mock.Of(); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs index b4876696b..5ec788d0b 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs @@ -10,7 +10,7 @@ namespace Maris.ConsoleApp.UnitTests.Hosting; public class ServiceCollectionExtensionsTest { [Fact] - public void コンソールアプリケーションの初期化処理を呼び出すと必要なサービスが登録される() + public void AddConsoleAppService_必要なサービスが登録される() { // Arrange var services = new ServiceCollection(); @@ -52,7 +52,7 @@ public void コンソールアプリケーションの初期化処理を呼び } [Fact] - public void ConsoleAppSettingsの設定処理を指定しないと既定のオブジェクトで初期化される() + public void AddConsoleAppSettings_ConsoleAppSettingsの設定処理を指定しない_既定のオブジェクトで初期化される() { // Arrange var services = new ServiceCollection(); @@ -69,7 +69,7 @@ public void ConsoleAppSettingsの設定処理を指定しないと既定のオ } [Fact] - public void ConsoleAppSettingsの設定処理を指定すると指定した値で初期化される() + public void AddConsoleAppSettings_ConsoleAppSettingsの設定処理を指定する_指定した値で初期化される() { // Arrange var services = new ServiceCollection(); @@ -91,7 +91,7 @@ public void ConsoleAppSettingsの設定処理を指定すると指定した値 } [Fact] - public void アセンブリ内にコマンドが登録されていない場合は例外() + public void アセンブリ内にコマンドが登録されていない_InvalidOperationExceptionが発生する() { // Arrange var services = new ServiceCollection(); @@ -119,7 +119,7 @@ public void アセンブリ内にコマンドが登録されていない場合 } [Fact] - public void 登録されていないコマンド名を指定した場合は検証エラーのエラーコードを伴ってアプリケーションが終了する() + public void 登録されていないコマンド名を指定_検証エラーのエラーコードを伴ってApplicationExceptionが発生する() { // Arrange var services = new ServiceCollection(); @@ -147,7 +147,7 @@ public void 登録されていないコマンド名を指定した場合は検 [Theory] [InlineData("test-command1", typeof(TestParameter1), typeof(TestCommand1))] [InlineData("test-command2", typeof(TestParameter2), typeof(TestCommand2))] - public void 登録されているコマンド名を指定するとDIコンテナーからConsoleAppContextが生成できる(string commandName, Type parameterType, Type commandType) + public void 登録されているコマンド名を指定_DIコンテナーからConsoleAppContextが生成できる(string commandName, Type parameterType, Type commandType) { // Arrange var services = new ServiceCollection(); From 001e285dd97d57ea13c890ddafb356c975881400 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:03:03 +0900 Subject: [PATCH 28/40] =?UTF-8?q?Arrange=E3=81=AE=E6=BC=8F=E3=82=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs index 1cd6a86e3..7afd6002b 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs @@ -88,7 +88,8 @@ public void ValidateAllParameter_入力パラメータのクラスにプロパ var command = new CommandImpl(); string commandName = "dummy-command"; var commandAttribute = new CommandAttribute(commandName, typeof(CommandImpl)); - var context = new ConsoleAppContext(commandAttribute, new object()); + var parameter = new object(); + var context = new ConsoleAppContext(commandAttribute, parameter); command.Initialize(context); // Act and Assert(例外が発生しないこと) @@ -102,7 +103,8 @@ public void ValidateAllParameter_入力パラメータのクラスにプロパ var command = new CommandImpl(); string commandName = "dummy-command"; var commandAttribute = new CommandAttribute(commandName, typeof(CommandImpl)); - var context = new ConsoleAppContext(commandAttribute, new NoDataAnnotationParameter()); + var parameter = new NoDataAnnotationParameter(); + var context = new ConsoleAppContext(commandAttribute, parameter); command.Initialize(context); // Act and Assert(例外が発生しないこと) From 769b1e02d3be356e8bdbcd88e49ca6b412d274ce Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:03:30 +0900 Subject: [PATCH 29/40] =?UTF-8?q?=E5=9E=8B=E3=81=AE=E8=AA=A4=E3=82=8A?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs index d088550ec..0fd511016 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/AsyncCommandTest.cs @@ -67,7 +67,7 @@ public void IAsyncCommandのExecuteAsync_ExecuteAsyncメソッドがコンテキ public void Initialize_パラメーターの型にインターフェースを使用できる() { // Arrange - var parameter = new ParameterWithInterface(); + IParameter parameter = new ParameterWithInterface(); var commandAttribute = new CommandAttribute("dummy-command", typeof(CommandWithInterface)); var context = new ConsoleAppContext(commandAttribute, parameter); var commandMock = new Mock(); From a59d92f2fa284fc65fc19db9f1c64e4cb6819d26 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:04:54 +0900 Subject: [PATCH 30/40] =?UTF-8?q?=E5=8D=98=E4=B8=80=E8=A6=81=E7=B4=A0?= =?UTF-8?q?=E3=81=AE=E3=82=B3=E3=83=AC=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E6=A4=9C=E8=A8=BC=E3=81=ABAssert.Single=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=86=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs index 7afd6002b..a015934ef 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandBaseTest.cs @@ -155,9 +155,7 @@ public void ValidateAllParameter_入力パラメータのクラスに検証属 // Assert var ex = Assert.Throws(action); - Assert.Collection( - ex.ValidationResults, - result => Assert.Equal("Param2 は 0 から 5 の間で設定してください。", result.ErrorMessage)); + Assert.Single(ex.ValidationResults, result => result.ErrorMessage == "Param2 は 0 から 5 の間で設定してください。"); } [Fact] From 407840db90e165c5f9a55dffa1769891443b5dad Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:06:39 +0900 Subject: [PATCH 31/40] =?UTF-8?q?=E9=85=8D=E5=88=97=E3=81=AE=E5=88=9D?= =?UTF-8?q?=E6=9C=9F=E5=8C=96=E5=87=A6=E7=90=86=E3=81=A7=E7=9F=AD=E7=B8=AE?= =?UTF-8?q?=E6=A7=8B=E6=96=87=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommandParameterTypeCollectionTest.cs | 24 +++++++------------ .../ServiceCollectionExtensionsTest.cs | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs index a14d071bc..46acdda92 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/CommandParameterTypeCollectionTest.cs @@ -43,7 +43,7 @@ public void AddCommandParameterTypeFrom_クラスの定義されていないア { // Arrange var collection = new CommandParameterTypeCollection(); - var testAssembly = new TestAssembly(Array.Empty()); + var testAssembly = new TestAssembly([]); // Act collection.AddCommandParameterTypeFrom(testAssembly); @@ -57,13 +57,7 @@ public void AddCommandParameterTypeFrom_パラメーターではないクラス { // Arrange var collection = new CommandParameterTypeCollection(); - var testAssembly = new TestAssembly( - new Type[] - { - typeof(int), - typeof(DateTime), - typeof(CommandParameterTypeCollection), - }); + var testAssembly = new TestAssembly([typeof(int), typeof(DateTime), typeof(CommandParameterTypeCollection)]); // Act collection.AddCommandParameterTypeFrom(testAssembly); @@ -78,14 +72,13 @@ public void AddCommandParameterTypeFrom_パラメーターを含むクラスが // Arrange var collection = new CommandParameterTypeCollection(); var testAssembly = new TestAssembly( - new Type[] - { + [ typeof(int), typeof(DateTime), typeof(CommandParameterTypeCollection), typeof(CommandParameter1), typeof(CommandParameter2), - }); + ]); // Act collection.AddCommandParameterTypeFrom(testAssembly); @@ -103,12 +96,11 @@ public void AddCommandParameterTypeFrom_同じ名前のコマンドがある_Arg // Arrange var collection = new CommandParameterTypeCollection(); var testAssembly = new TestAssembly( - new Type[] - { + [ typeof(CommandParameter1), typeof(CommandParameter2), typeof(CommandParameter1Dash), - }); + ]); // Act var action = () => collection.AddCommandParameterTypeFrom(testAssembly); @@ -123,8 +115,8 @@ public void LoadedAssemblies_読み込んだアセンブリのリストを取得 { // Arrange var collection = new CommandParameterTypeCollection(); - var assembly1 = new TestAssembly(Array.Empty()); - var assembly2 = new TestAssembly(Array.Empty()); + var assembly1 = new TestAssembly([]); + var assembly2 = new TestAssembly([]); collection.AddCommandParameterTypeFrom(assembly1); collection.AddCommandParameterTypeFrom(assembly2); diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs index 5ec788d0b..8e913d8b3 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ServiceCollectionExtensionsTest.cs @@ -102,7 +102,7 @@ public void アセンブリ内にコマンドが登録されていない_Invalid services.AddSingleton(provider => testApplicationProcess); var types = Array.Empty(); var assembly1 = new TestAssembly1(types); - var assembly2 = new TestAssembly2(Array.Empty()); + var assembly2 = new TestAssembly2([]); // Act services.AddConsoleAppContext(args, types => From 9e365116aea264b8bd258e91703540e964489beb Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:08:09 +0900 Subject: [PATCH 32/40] =?UTF-8?q?=E5=8D=98=E4=B8=80=E8=A6=81=E7=B4=A0?= =?UTF-8?q?=E3=81=AE=E3=82=B3=E3=83=AC=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E6=A4=9C=E8=A8=BC=E3=81=ABAssert.Single=E3=82=92?= =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/CommandExecutorTest.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs index 10aa5280d..a1f1106e1 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs @@ -114,9 +114,7 @@ public async Task ExecuteCommandAsync_パラメーターの入力検証に失敗 // Assert var exception = await Assert.ThrowsAsync(action); - Assert.Collection( - exception.ValidationResults, - result => Assert.Equal("StringParam は 5 文字以下に設定してください。", result.ErrorMessage)); + Assert.Single(exception.ValidationResults, result => result.ErrorMessage == "StringParam は 5 文字以下に設定してください。"); } [Fact] @@ -140,9 +138,7 @@ public async Task ExecuteCommandAsync_パラメーターのカスタム入力検 // Assert var exception = await Assert.ThrowsAsync(action); - Assert.Collection( - exception.ValidationResults, - result => Assert.Equal("Validate メソッド内で検証", result.ErrorMessage)); + Assert.Single(exception.ValidationResults, result => result.ErrorMessage == "Validate メソッド内で検証"); } [Fact] From 0e76ae00f8055e226453747db0576a978d814967 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:08:30 +0900 Subject: [PATCH 33/40] =?UTF-8?q?=E9=85=8D=E5=88=97=E3=81=AE=E5=88=9D?= =?UTF-8?q?=E6=9C=9F=E5=8C=96=E5=87=A6=E7=90=86=E3=81=A7=E7=9F=AD=E7=B8=AE?= =?UTF-8?q?=E6=A7=8B=E6=96=87=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs index a1f1106e1..db71039c1 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/CommandExecutorTest.cs @@ -334,7 +334,7 @@ private class ValidatableParameter : IValidatableObject { public IEnumerable Validate(ValidationContext validationContext) { - yield return new ValidationResult("Validate メソッド内で検証", new string[] { "dummy-member-name" }); + yield return new ValidationResult("Validate メソッド内で検証", ["dummy-member-name"]); } } From c4cdfa654d37dcfd1e0a537b394bd8a7547af940 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:09:19 +0900 Subject: [PATCH 34/40] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=82=AF=E3=82=BF=E3=83=BC=E3=81=AE=E5=91=BC=E3=81=B3?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=81=A7=E7=9F=AD=E7=B8=AE=E6=A7=8B=E6=96=87?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/InvalidParameterExceptionTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs index e9ff841e9..23c89dbf3 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Core/InvalidParameterExceptionTest.cs @@ -26,7 +26,7 @@ public void Message_検証結果が1件登録されている_メンバー名と var memberNames = new string[] { "param1", "param2" }; var validationResults = new List { - new ValidationResult(errorMessage, memberNames), + new(errorMessage, memberNames), }; var ex = new InvalidParameterException(validationResults); @@ -47,8 +47,8 @@ public void Message_検証結果が2件登録されている場合_メンバー var memberNames2 = new string[] { "param2", "param3" }; var validationResults = new List { - new ValidationResult(errorMessage1, memberNames1), - new ValidationResult(errorMessage2, memberNames2), + new(errorMessage1, memberNames1), + new(errorMessage2, memberNames2), }; var ex = new InvalidParameterException(validationResults); @@ -80,8 +80,8 @@ public void ValidationResults_検証結果のリストを指定_指定したリ string errorMessage2 = "error message2"; var results = new List { - new ValidationResult(errorMessage1), - new ValidationResult(errorMessage2), + new(errorMessage1), + new(errorMessage2), }; var ex = new InvalidParameterException(validationResults: results); From 25d9ac9b66c4e5cc48ca721bd8a889ac950d95bd Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:10:26 +0900 Subject: [PATCH 35/40] =?UTF-8?q?MemberData=E3=81=AE=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=82=BD=E3=83=BC=E3=82=B9=E3=81=ABTheoryData?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hosting/ConsoleAppHostedServiceTest.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs index 0c15bda4c..25d96baeb 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs @@ -8,12 +8,7 @@ namespace Maris.ConsoleApp.UnitTests.Hosting; public class ConsoleAppHostedServiceTest : TestBase { - public ConsoleAppHostedServiceTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - - public static IEnumerable GetContextsAndCommands() + public static TheoryData GetContextsAndCommands() { // パターン1:正常終了するコマンド var commandAttribute1 = new CommandAttribute("dummy-command", typeof(SyncCommandImpl)); @@ -33,12 +28,13 @@ public static IEnumerable GetContextsAndCommands() var context3 = new ConsoleAppContext(commandAttribute3, parameter3); var command3 = new TestCommand(); - return new List + var data = new TheoryData { - new object[] { context1, command1 }, - new object[] { context2, command2 }, - new object[] { context3, command3 }, + { context1, command1 }, + { context2, command2 }, + { context3, command3 }, }; + return data; } [Fact] From 9f7a3beb408dff39dece52fc7835fb85f537503c Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:11:10 +0900 Subject: [PATCH 36/40] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=A4=E3=83=9E?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=83=BC=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hosting/ConsoleAppHostedServiceTest.cs | 2 +- .../Hosting/DefaultCommandManagerTest.cs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs index 25d96baeb..86f5e56e8 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/ConsoleAppHostedServiceTest.cs @@ -6,7 +6,7 @@ namespace Maris.ConsoleApp.UnitTests.Hosting; -public class ConsoleAppHostedServiceTest : TestBase +public class ConsoleAppHostedServiceTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { public static TheoryData GetContextsAndCommands() { diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs index c7b573aa0..2716f5fb2 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.UnitTests/Hosting/DefaultCommandManagerTest.cs @@ -94,13 +94,8 @@ protected internal override ICommandResult Execute(TestParameter parameter) => throw new NotImplementedException(); } - private class DefaultCommandManagerMock : DefaultCommandManager + private class DefaultCommandManagerMock(ConsoleAppContext context, IServiceProvider provider) : DefaultCommandManager(context, provider) { - public DefaultCommandManagerMock(ConsoleAppContext context, IServiceProvider provider) - : base(context, provider) - { - } - internal override CommandBase CreateCommandInScope() => new TestCommand(); } From de21d3867f4a2413b050d6533d8c6f6202342926 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:13:44 +0900 Subject: [PATCH 37/40] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=A7=E3=81=AESA1602=E3=81=AE=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E3=82=92=E7=84=A1=E5=8A=B9=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/ConsoleAppWithDI/solution/tests/.editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/ConsoleAppWithDI/solution/tests/.editorconfig b/samples/ConsoleAppWithDI/solution/tests/.editorconfig index b8668a97c..6d86a4800 100644 --- a/samples/ConsoleAppWithDI/solution/tests/.editorconfig +++ b/samples/ConsoleAppWithDI/solution/tests/.editorconfig @@ -4,3 +4,4 @@ dotnet_diagnostic.IDE0039.severity=none dotnet_diagnostic.SA0001.severity=none dotnet_diagnostic.SA1123.severity=none dotnet_diagnostic.SA1600.severity=none +dotnet_diagnostic.SA1602.severity=none From b0b24a51daf25ed9d932282700117d69bdd2fb9f Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:18:16 +0900 Subject: [PATCH 38/40] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=A4=E3=83=9E?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=83=BC=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScopeTests/Commands/Command.cs | 12 +++--------- .../ScopeTests/ScopedTest.cs | 7 +------ .../ScopeTests/SingletonTest.cs | 7 +------ .../ScopeTests/TestObject1.cs | 6 ++---- .../ScopeTests/TransientTest.cs | 7 +------ 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/Commands/Command.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/Commands/Command.cs index fd0685568..fe2c5356e 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/Commands/Command.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/Commands/Command.cs @@ -2,17 +2,11 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests.Commands; -internal class Command : SyncCommand +internal class Command(TestObject1 obj1, TestObject2 obj2) : SyncCommand { internal const string CommandName = "scope-test"; - private readonly TestObject1 obj1; - private readonly TestObject2 obj2; - - public Command(TestObject1 obj1, TestObject2 obj2) - { - this.obj1 = obj1; - this.obj2 = obj2; - } + private readonly TestObject1 obj1 = obj1; + private readonly TestObject2 obj2 = obj2; protected override ICommandResult Execute(Parameter parameter) { diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs index 76d01f897..6cd7fbfcc 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ScopedTest.cs @@ -7,13 +7,8 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; [Collection(nameof(ScopeTests))] -public class ScopedTest : TestBase +public class ScopedTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public ScopedTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - [Fact] public async Task Scopedで登録したインスタンスはコマンド実行時に1回だけ初期化される() { diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs index 0e682496b..5c5180c33 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/SingletonTest.cs @@ -7,13 +7,8 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; [Collection(nameof(ScopeTests))] -public class SingletonTest : TestBase +public class SingletonTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public SingletonTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - [Fact] public async Task Singletonで登録したインスタンスはコマンド実行時に1回だけ初期化される() { diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject1.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject1.cs index 58d3d7498..355d5f1ed 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject1.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject1.cs @@ -1,10 +1,8 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; -internal class TestObject1 : TestObjectBase +internal class TestObject1(TestObject2 obj2) : TestObjectBase { - private readonly TestObject2 obj2; - - public TestObject1(TestObject2 obj2) => this.obj2 = obj2; + private readonly TestObject2 obj2 = obj2; internal void DoSomething() { diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs index f55cd5359..7cc0b4f03 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TransientTest.cs @@ -7,13 +7,8 @@ namespace Maris.ConsoleApp.IntegrationTests.ScopeTests; [Collection(nameof(ScopeTests))] -public class TransientTest : TestBase +public class TransientTest(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) { - public TransientTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - [Fact] public async Task Transientで登録したインスタンスはインジェクション時に毎回初期化される() { From 45fe187c02f2a9b7ab430bfd0b1a3dc2101ac0b1 Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:18:45 +0900 Subject: [PATCH 39/40] =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=81=AE?= =?UTF-8?q?=E5=88=9D=E6=9C=9F=E5=8C=96=E5=87=A6=E7=90=86=E3=81=A7=E7=9F=AD?= =?UTF-8?q?=E7=B8=AE=E6=A7=8B=E6=96=87=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScopeTests/ObjectStateHistory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ObjectStateHistory.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ObjectStateHistory.cs index ea3c3d305..6c0ca285c 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ObjectStateHistory.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/ObjectStateHistory.cs @@ -2,7 +2,7 @@ internal static class ObjectStateHistory { - private static readonly List HistoryStore = new(); + private static readonly List HistoryStore = []; internal static IReadOnlyCollection Histories => HistoryStore.AsReadOnly(); From 386fed97a62c95d043810b4ca12b05e722e2a55d Mon Sep 17 00:00:00 2001 From: tsuna-can-se <61451753+tsuna-can-se@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:19:00 +0900 Subject: [PATCH 40/40] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=B3?= =?UTF-8?q?=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9=E3=82=AF=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScopeTests/TestObject2.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject2.cs b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject2.cs index 79fdcbabf..32e64efb3 100644 --- a/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject2.cs +++ b/samples/ConsoleAppWithDI/solution/tests/Maris.ConsoleApp.IntegrationTests/ScopeTests/TestObject2.cs @@ -2,9 +2,5 @@ internal class TestObject2 : TestObjectBase { - public TestObject2() - { - } - internal void DoSomething() => this.LogHistory(); }