瀏覽代碼

Get by id entity test

pull/154/head
bronjaermin 3 年之前
父節點
當前提交
47fc3d8c88
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20
    0
      Diligent.WebAPI.Tests/Services/AdServiceTests.cs

+ 20
- 0
Diligent.WebAPI.Tests/Services/AdServiceTests.cs 查看文件

@@ -104,6 +104,26 @@ namespace Diligent.WebAPI.Tests.Services
await Assert.ThrowsAsync<EntityNotFoundException>(async () => await adService.GetByIdAsync(1000));
}

[Fact]
public async Task GetByIdEntity_ShouldReturnAd_WhenAdExists()
{
var databaseContext = await Helpers<Ad>.GetDatabaseContext(_ads);
AdService adService = new(databaseContext, _mapper, _technologyService, _logger);

var result = await adService.GetByIdEntityAsync(1);

result.Should().BeEquivalentTo(_ad);
}

[Fact]
public async Task GetByIdEntity_ShouldThrowEntityNotFoundException_WhenAdDontExists()
{
var databaseContext = await Helpers<Ad>.GetDatabaseContext(_ads);
AdService adService = new(databaseContext, _mapper, _technologyService, _logger);

await Assert.ThrowsAsync<EntityNotFoundException>(async () => await adService.GetByIdEntityAsync(1000));
}

[Fact]
public async Task GetAdDetailsById_ShouldReturnAd_WhenAdExists()
{

Loading…
取消
儲存