Интеграционные тесты: обновление wellOperation

This commit is contained in:
Olga Nemt 2024-01-25 17:13:56 +05:00
parent 4bd0a835fc
commit f6e638f8db
3 changed files with 35 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using AsbCloudApp.Data;
using Microsoft.AspNetCore.Mvc;
using Refit;
namespace AsbCloudWebApi.IntegrationTests.Clients;
@ -10,4 +11,7 @@ public interface IWellOperationClient
[Post(BaseRoute + "/{idType}/{deleteBeforeInsert}")]
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);
}

View File

@ -151,4 +151,34 @@ public class WellOperationControllerTest : BaseIntegrationTest
//assert
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);
}
}

View File

@ -19,7 +19,7 @@ namespace AsbCloudWebApi.IntegrationTests.Data
{
new()
{
Id = 2,
Id = 1,
IdWell = 1,
IdType = 1,
DateStart = DateTimeOffset.UtcNow.AddDays(-1),