forked from ddrilling/AsbCloudServer
Добавлен интеграционный тест, который проверяет пагинацию в ГГД
This commit is contained in:
parent
caf88d371a
commit
59d295a4f2
@ -19,7 +19,7 @@ public interface IWellOperationClient
|
|||||||
Task<IApiResponse<int>> UpdateRangeAsync(int idWell, [Body] IEnumerable<WellOperationDto> dtos);
|
Task<IApiResponse<int>> UpdateRangeAsync(int idWell, [Body] IEnumerable<WellOperationDto> dtos);
|
||||||
|
|
||||||
[Get(BaseRoute)]
|
[Get(BaseRoute)]
|
||||||
Task<IApiResponse<PaginationContainer<WellOperationDto>>> GetPageOperationsPlanAsync(int idWell, [Query] WellOperationRequestBase request);
|
Task<IApiResponse<PaginationContainer<WellOperationDto>>> GetPageOperationsAsync(int idWell, [Query] WellOperationRequestBase request);
|
||||||
|
|
||||||
[Multipart]
|
[Multipart]
|
||||||
[Post(BaseRoute + "/parse/{idType}")]
|
[Post(BaseRoute + "/parse/{idType}")]
|
||||||
|
@ -89,9 +89,12 @@ public class WellOperationControllerTest : BaseIntegrationTest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetPageOperationsPlanAsync_returns_success()
|
public async Task GetPageOperationsAsync_returns_first_page()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
|
const int pageSize = 10;
|
||||||
|
const int pageIndex = 0;
|
||||||
|
|
||||||
var well = await dbContext.Wells.FirstAsync();
|
var well = await dbContext.Wells.FirstAsync();
|
||||||
var entity = CreateWellOperation(well.Id);
|
var entity = CreateWellOperation(well.Id);
|
||||||
dbContext.WellOperations.Add(entity);
|
dbContext.WellOperations.Add(entity);
|
||||||
@ -104,17 +107,22 @@ public class WellOperationControllerTest : BaseIntegrationTest
|
|||||||
|
|
||||||
var request = new WellOperationRequestBase
|
var request = new WellOperationRequestBase
|
||||||
{
|
{
|
||||||
OperationType = WellOperation.IdOperationTypePlan
|
OperationType = WellOperation.IdOperationTypePlan,
|
||||||
|
Skip = pageIndex,
|
||||||
|
Take = pageSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await client.GetPageOperationsPlanAsync(well.Id, request);
|
var response = await client.GetPageOperationsAsync(well.Id, request);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(response.StatusCode, HttpStatusCode.OK);
|
Assert.Equal(response.StatusCode, HttpStatusCode.OK);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.Single(response.Content.Items);
|
|
||||||
|
|
||||||
|
var totalExpected = response.Content.Count - pageSize * pageIndex;
|
||||||
|
Assert.Equal(totalExpected, response.Content.Items.Count());
|
||||||
|
|
||||||
|
Assert.Single(response.Content.Items);
|
||||||
var actualDto = response.Content.Items.First();
|
var actualDto = response.Content.Items.First();
|
||||||
|
|
||||||
MatchHelper.Match(dto, actualDto);
|
MatchHelper.Match(dto, actualDto);
|
||||||
|
Loading…
Reference in New Issue
Block a user