Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

メソッド名の ByAdmin を ForAdmin に変更 #2186

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -277,9 +277,9 @@ public async Task UpdateCatalogItemAsync(
/// <param name="cancellationToken">キャンセルトークン。</param>
/// <returns>カタログページと総アイテム数のタプルを返す非同期処理を表すタスク。</returns>
/// <exception cref="PermissionDeniedException">更新権限がない場合。</exception>
public async Task<(IReadOnlyList<CatalogItem> ItemsOnPage, int TotalItems)> GetCatalogItemsByAdminAsync(int skip, int take, long? brandId, long? categoryId, CancellationToken cancellationToken = default)
public async Task<(IReadOnlyList<CatalogItem> ItemsOnPage, int TotalItems)> GetCatalogItemsForAdminAsync(int skip, int take, long? brandId, long? categoryId, CancellationToken cancellationToken = default)
{
this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsByAdminAsyncStart, brandId, categoryId);
this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsForAdminAsyncStart, brandId, categoryId);

if (!this.userStore.IsInRole(Roles.Admin))
{
@@ -298,7 +298,7 @@ public async Task UpdateCatalogItemAsync(
scope.Complete();
}

this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsByAdminAsyncEnd, brandId, categoryId);
this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemsForAdminAsyncEnd, brandId, categoryId);
return (ItemsOnPage: itemsOnPage, TotalItems: totalItems);
}

@@ -310,9 +310,9 @@ public async Task UpdateCatalogItemAsync(
/// <returns>カタログアイテム。</returns>
/// <exception cref="PermissionDeniedException">更新権限がない場合。</exception>
/// <exception cref="CatalogItemNotExistingInRepositoryException">取得対象のカタログアイテムが存在しなかった場合。</exception>
public async Task<CatalogItem?> GetCatalogItemByAdminAsync(long catalogItemId, CancellationToken cancellationToken = default)
public async Task<CatalogItem?> GetCatalogItemForAdminAsync(long catalogItemId, CancellationToken cancellationToken = default)
{
this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemByAdminAsyncStart, catalogItemId);
this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemForAdminAsyncStart, catalogItemId);

if (!this.userStore.IsInRole(Roles.Admin))
{
@@ -332,7 +332,7 @@ public async Task UpdateCatalogItemAsync(
scope.Complete();
}

this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemByAdminAsyncEnd, catalogItemId);
this.logger.LogDebug(Events.DebugEvent, LogMessages.CatalogApplicationService_GetCatalogItemForAdminAsyncEnd, catalogItemId);
return catalogItem;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -138,10 +138,10 @@
<data name="CatalogApplicationService_DeleteItemFromCatalogAsyncStart" xml:space="preserve">
<value>カタログアイテム ID: {CatalogItemId} のカタログアイテムを削除します。</value>
</data>
<data name="CatalogApplicationService_GetCatalogItemByAdminAsyncEnd" xml:space="preserve">
<data name="CatalogApplicationService_GetCatalogItemForAdminAsyncEnd" xml:space="preserve">
<value>管理者がカタログアイテム ID: {CatalogItemId} のカタログアイテムを取得しました。</value>
</data>
<data name="CatalogApplicationService_GetCatalogItemByAdminAsyncStart" xml:space="preserve">
<data name="CatalogApplicationService_GetCatalogItemForAdminAsyncStart" xml:space="preserve">
<value>管理者がカタログアイテム ID: {CatalogItemId} のカタログアイテムを取得します。</value>
</data>
<data name="CatalogApplicationService_GetCatalogItemsAsyncEnd" xml:space="preserve">
@@ -150,10 +150,10 @@
<data name="CatalogApplicationService_GetCatalogItemsAsyncStart" xml:space="preserve">
<value>カタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカテゴリ情報を取得します。</value>
</data>
<data name="CatalogApplicationService_GetCatalogItemsByAdminAsyncEnd" xml:space="preserve">
<data name="CatalogApplicationService_GetCatalogItemsForAdminAsyncEnd" xml:space="preserve">
<value>管理者がカタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカタログ情報を取得しました。</value>
</data>
<data name="CatalogApplicationService_GetCatalogItemsByAdminAsyncStart" xml:space="preserve">
<data name="CatalogApplicationService_GetCatalogItemsForAdminAsyncStart" xml:space="preserve">
<value>管理者がカタログブランド ID: {CatalogBrandId} 、カタログカテゴリ ID: {CatalogCategoryId} のカタログ情報を取得します。</value>
</data>
<data name="CatalogApplicationService_UpdateCatalogItemAsyncEnd" xml:space="preserve">
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ public async Task<IActionResult> GetCatalogItemAsync(long catalogItemId)

try
{
catalogItem = await this.service.GetCatalogItemByAdminAsync(catalogItemId);
catalogItem = await this.service.GetCatalogItemForAdminAsync(catalogItemId);
}
catch (PermissionDeniedException ex)
{
@@ -114,7 +114,7 @@ public async Task<IActionResult> GetByQueryAsync([FromQuery] FindCatalogItemsQue
try
{
itemsAndCount =
await this.service.GetCatalogItemsByAdminAsync(
await this.service.GetCatalogItemsForAdminAsync(
skip: query.GetSkipCount(),
take: query.PageSize,
brandId: query.BrandId,
Original file line number Diff line number Diff line change
@@ -618,7 +618,7 @@ public async Task UpdateCatalogItemAsync_権限なし_PermissionDeniedException
}

[Fact]
public async Task GetCatalogItemsByAdminAsync_リポジトリのFindAsyncを一度だけ呼び出す()
public async Task GetCatalogItemsForAdminAsync_リポジトリのFindAsyncを一度だけ呼び出す()
{
// Arrange
var catalogRepositoryMock = new Mock<ICatalogRepository>();
@@ -635,7 +635,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのFindAsyncを一
var targetCategoryId = 1;

// Act
_ = await service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId);
_ = await service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId);

// Assert
catalogRepositoryMock.Verify(
@@ -644,7 +644,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのFindAsyncを一
}

[Fact]
public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1回呼出す()
public async Task GetCatalogItemsForAdminAsync_リポジトリのCountAsyncを1回呼出す()
{
// Arrange
var catalogRepositoryMock = new Mock<ICatalogRepository>();
@@ -661,7 +661,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1
var targetCategoryId = 1;

// Act
_ = await service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId);
_ = await service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId);

// Assert
catalogRepositoryMock.Verify(
@@ -670,7 +670,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1
}

[Fact]
public async Task GetCatalogItemsByAdminAsync_ページネーションされたアイテムと総アイテム数が返却される()
public async Task GetCatalogItemsForAdminAsync_ページネーションされたアイテムと総アイテム数が返却される()
{
// Arrange
var skip = 0;
@@ -693,15 +693,15 @@ public async Task GetCatalogItemsByAdminAsync_ページネーションされた
var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepositoryMock.Object, catalogCategoryRepositoryMock.Object, userStoreMock.Object, catalogDomainServiceMock, logger);

// Act
var (list, totalItems) = await service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId);
var (list, totalItems) = await service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId);

// Assert
Assert.Equal(targetItems, list);
Assert.Equal(targetTotalItems, totalItems);
}

[Fact]
public async Task GetCatalogItemsByAdminAsync_権限なし_PermissionDeniedExceptionが発生()
public async Task GetCatalogItemsForAdminAsync_権限なし_PermissionDeniedExceptionが発生()
{
// Arrange
var catalogRepositoryMock = new Mock<ICatalogRepository>();
@@ -718,14 +718,14 @@ public async Task GetCatalogItemsByAdminAsync_権限なし_PermissionDeniedExcep
var targetCategoryId = 1;

// Act
var action = () => service.GetCatalogItemsByAdminAsync(skip, take, targetBrandId, targetCategoryId);
var action = () => service.GetCatalogItemsForAdminAsync(skip, take, targetBrandId, targetCategoryId);

// Assert
await Assert.ThrowsAsync<PermissionDeniedException>(action);
}

[Fact]
public async Task GetCatalogItemByAdminAsync_リポジトリのGetAsyncを一度だけ呼び出す()
public async Task GetCatalogItemForAdminAsync_リポジトリのGetAsyncを一度だけ呼び出す()
{
// Arrange
var targetId = 1;
@@ -743,14 +743,14 @@ public async Task GetCatalogItemByAdminAsync_リポジトリのGetAsyncを一度
var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, userStoreMock.Object, catalogDomainServiceMock, logger);

// Act
_ = await service.GetCatalogItemByAdminAsync(targetId);
_ = await service.GetCatalogItemForAdminAsync(targetId);

// Assert
catalogRepositoryMock.Verify(r => r.GetAsync(targetId, AnyToken), Times.Once);
}

[Fact]
public async Task GetCatalogItemByAdminAsync_権限なし_PermissionDeniedExceptionが発生()
public async Task GetCatalogItemForAdminAsync_権限なし_PermissionDeniedExceptionが発生()
{
// Arrange
var targetId = 1;
@@ -768,14 +768,14 @@ public async Task GetCatalogItemByAdminAsync_権限なし_PermissionDeniedExcept
var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, userStoreMock.Object, catalogDomainServiceMock, logger);

// Act
var action = () => service.GetCatalogItemByAdminAsync(targetId);
var action = () => service.GetCatalogItemForAdminAsync(targetId);

// Assert
await Assert.ThrowsAsync<PermissionDeniedException>(action);
}

[Fact]
public async Task GetCatalogItemByAdminAsync_対象のアイテムが存在しない_CatalogItemNotExistingInRepositoryExceptionが発生()
public async Task GetCatalogItemForAdminAsync_対象のアイテムが存在しない_CatalogItemNotExistingInRepositoryExceptionが発生()
{
// Arrange
var targetId = 999;
@@ -792,7 +792,7 @@ public async Task GetCatalogItemByAdminAsync_対象のアイテムが存在し
var service = new CatalogApplicationService(catalogRepositoryMock.Object, catalogBrandRepository, catalogCategoryRepository, userStoreMock.Object, catalogDomainServiceMock, logger);

// Act
var action = () => service.GetCatalogItemByAdminAsync(targetId);
var action = () => service.GetCatalogItemForAdminAsync(targetId);

// Assert
await Assert.ThrowsAsync<CatalogItemNotExistingInRepositoryException>(action);