Skip to content

Commit

Permalink
メソッド名のByAdminをForAdminに修正 (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
KentaHizume authored Dec 26, 2024
1 parent ce162d0 commit 75735a1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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);
}

Expand All @@ -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))
{
Expand All @@ -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
Expand Up @@ -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">
Expand All @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
Expand All @@ -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(
Expand All @@ -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>();
Expand All @@ -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(
Expand All @@ -670,7 +670,7 @@ public async Task GetCatalogItemsByAdminAsync_リポジトリのCountAsyncを1
}

[Fact]
public async Task GetCatalogItemsByAdminAsync_ページネーションされたアイテムと総アイテム数が返却される()
public async Task GetCatalogItemsForAdminAsync_ページネーションされたアイテムと総アイテム数が返却される()
{
// Arrange
var skip = 0;
Expand All @@ -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>();
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 75735a1

Please sign in to comment.