diff --git a/AsbCloudWebApi.IntegrationTests/Controllers/WellOperations/WellOperationControllerTest.cs b/AsbCloudWebApi.IntegrationTests/Controllers/WellOperations/WellOperationControllerTest.cs index 1a700189..006379d2 100644 --- a/AsbCloudWebApi.IntegrationTests/Controllers/WellOperations/WellOperationControllerTest.cs +++ b/AsbCloudWebApi.IntegrationTests/Controllers/WellOperations/WellOperationControllerTest.cs @@ -188,7 +188,61 @@ public class WellOperationControllerTest : BaseIntegrationTest Assert.True(response.ContentHeaders?.ContentLength > 0); } - private static WellOperation CreateWellOperation(int idWell, int idType = WellOperation.IdOperationTypePlan) => + [Theory] + [InlineData(WellOperation.IdOperationTypePlan)] + [InlineData(WellOperation.IdOperationTypeFact)] + public async Task GetPageOperationsAsyncWithDaysAndNpv_returns_success(int idType) + { + //arrange + const int pageSize = 10; + const int pageIndex = 0; + + var well = await dbContext.Wells.FirstAsync(); + var entity1 = CreateWellOperation(well.Id); + + var entity2 = entity1.Adapt(); + entity2.DateStart = entity2.DateStart.AddDays(1); + entity2.IdCategory = WellOperationCategory.IdNonProductiveTime; + entity2.DurationHours = 2; + + var entity3 = entity2.Adapt(); + entity3.DateStart = entity3.DateStart.AddDays(1); + entity3.IdCategory = WellOperationCategory.IdNonProductiveTime; + entity3.DurationHours = 3; + + dbContext.WellOperations.Add(entity1); + dbContext.WellOperations.Add(entity2); + dbContext.WellOperations.Add(entity3); + + await dbContext.SaveChangesAsync(); + + + var request = new WellOperationRequestBase + { + OperationType = WellOperation.IdOperationTypePlan, + Skip = pageIndex, + Take = pageSize, + }; + + //act + var response = await client.GetPageOperationsAsync(well.Id, request); + + //assert + Assert.Equal(response.StatusCode, HttpStatusCode.OK); + Assert.NotNull(response.Content); + + var items = response.Content.Items.ToArray(); + + Assert.Equal(0, items[0].Day); + Assert.Equal(1, items[1].Day); + Assert.Equal(2, items[2].Day); + + Assert.Equal(0, items[0].NptHours); + Assert.Equal(2, items[1].NptHours); + Assert.Equal(5, items[2].NptHours); + } + + private static WellOperation CreateWellOperation(int idWell, int idType = WellOperation.IdOperationTypePlan) => new() { IdWell = idWell,