forked from ddrilling/AsbCloudServer
Интеграционные тесты: обновление wellOperation
This commit is contained in:
parent
4bd0a835fc
commit
f6e638f8db
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Refit;
|
using Refit;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.IntegrationTests.Clients;
|
namespace AsbCloudWebApi.IntegrationTests.Clients;
|
||||||
@ -10,4 +11,7 @@ public interface IWellOperationClient
|
|||||||
[Post(BaseRoute + "/{idType}/{deleteBeforeInsert}")]
|
[Post(BaseRoute + "/{idType}/{deleteBeforeInsert}")]
|
||||||
Task<IApiResponse<int>> InsertRangeAsync(int idWell, int idType, bool deleteBeforeInsert, [Body] IEnumerable<WellOperationDto> dtos);
|
Task<IApiResponse<int>> InsertRangeAsync(int idWell, int idType, bool deleteBeforeInsert, [Body] IEnumerable<WellOperationDto> dtos);
|
||||||
|
|
||||||
|
[Put(BaseRoute + "/{idOperation}")]
|
||||||
|
Task<IApiResponse<int>> UpdateAsync(int idWell, int idOperation, [FromBody] WellOperationDto value, CancellationToken token);
|
||||||
|
|
||||||
}
|
}
|
@ -151,4 +151,34 @@ public class WellOperationControllerTest : BaseIntegrationTest
|
|||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Успешное обновление операции
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateAsync_returns_success()
|
||||||
|
{
|
||||||
|
//act
|
||||||
|
var dto = dtos.FirstOrDefault()!;
|
||||||
|
var response = await wellOperationClient.UpdateAsync(idWell, 1, dto, CancellationToken.None);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Неуспешное обновление операции
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateAsync_returns_error()
|
||||||
|
{
|
||||||
|
//act
|
||||||
|
var dto = dtosWithError.LastOrDefault()!;
|
||||||
|
var response = await wellOperationClient.UpdateAsync(idWell, 1, dto, CancellationToken.None);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ namespace AsbCloudWebApi.IntegrationTests.Data
|
|||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = 2,
|
Id = 1,
|
||||||
IdWell = 1,
|
IdWell = 1,
|
||||||
IdType = 1,
|
IdType = 1,
|
||||||
DateStart = DateTimeOffset.UtcNow.AddDays(-1),
|
DateStart = DateTimeOffset.UtcNow.AddDays(-1),
|
||||||
|
Loading…
Reference in New Issue
Block a user