2024-06-21 09:53:45 +05:00
|
|
|
|
using AsbCloudApp.Data.ProcessMaps;
|
|
|
|
|
using AsbCloudDb.Model.ProcessMaps;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
|
|
|
|
|
public class ProcessMapPlanSlideControllerTest : ProcessMapPlanBaseControllerTest<ProcessMapPlanSlide, ProcessMapPlanSlideDto>
|
|
|
|
|
{
|
|
|
|
|
private readonly ProcessMapPlanSlideDto dto = new ProcessMapPlanSlideDto()
|
|
|
|
|
{
|
|
|
|
|
IdWell = 1,
|
|
|
|
|
DepthStart = 1,
|
|
|
|
|
DepthEnd = 2,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
RopMax = 3,
|
|
|
|
|
PressureMax = 4,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
DifferentialPressure = 5,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
DifferentialPressureMax = 6,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
WeightOnBit = 7,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
WeightOnBitMax = 8,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
FlowRate = 9,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
FlowRateMax = 10,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
Spring = 11,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
Buckling = 12,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
Id = 0,
|
|
|
|
|
IdWellSectionType = 1,
|
|
|
|
|
Note = "13"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly ProcessMapPlanSlide entity = new ProcessMapPlanSlide()
|
|
|
|
|
{
|
|
|
|
|
IdWell = 1,
|
|
|
|
|
DepthEnd = 10,
|
|
|
|
|
DepthStart = 2,
|
|
|
|
|
DifferentialPressure = 3,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
DifferentialPressureMax = 4,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
FlowRate = 5,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
FlowRateMax = 6,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
Id = 0,
|
|
|
|
|
IdWellSectionType = 1,
|
|
|
|
|
Note = "1",
|
2024-06-30 11:11:09 +05:00
|
|
|
|
PressureMax = 2,
|
|
|
|
|
RopMax = 5,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
WeightOnBit = 8,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
WeightOnBitMax = 9,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
IdAuthor = 1,
|
|
|
|
|
IdEditor = 1,
|
|
|
|
|
Creation = DateTimeOffset.UtcNow,
|
|
|
|
|
Spring = 10,
|
2024-06-30 11:11:09 +05:00
|
|
|
|
Buckling = 11,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public ProcessMapPlanSlideControllerTest(WebAppFactoryFixture factory) : base(factory, "ProcessMapPlanSlide")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override ProcessMapPlanSlide? GetByWellId()
|
|
|
|
|
{
|
|
|
|
|
var entity = dbContext
|
|
|
|
|
.Set<ProcessMapPlanSlide>()
|
|
|
|
|
.Where(p => p.WeightOnBit == dto.WeightOnBit)
|
2024-06-30 11:11:09 +05:00
|
|
|
|
.Where(p => p.WeightOnBitMax == dto.WeightOnBitMax)
|
2024-06-21 09:53:45 +05:00
|
|
|
|
.Where(p => p.Note == dto.Note)
|
|
|
|
|
.FirstOrDefault(p => p.IdWell == dto.IdWell);
|
|
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override ProcessMapPlanSlide GetByNote(
|
|
|
|
|
DbSet<ProcessMapPlanSlide> dbSet,
|
|
|
|
|
ProcessMapPlanSlideDto dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = dbSet.First(p => p.Note == dto.Note);
|
|
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override ProcessMapPlanSlideDto GetByNote(
|
|
|
|
|
IEnumerable<ProcessMapPlanSlideDto> dtos,
|
|
|
|
|
ProcessMapPlanSlideDto dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = dtos.First(p => p.Note == dto.Note);
|
|
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task InsertRange_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await InsertRangeSuccess(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task InsertRange_returns_BadRequest_for_IdWellSectionType()
|
|
|
|
|
{
|
|
|
|
|
//arrange
|
|
|
|
|
var badDto = dto.Adapt<ProcessMapPlanSlideDto>();
|
|
|
|
|
badDto.IdWellSectionType = int.MaxValue;
|
|
|
|
|
|
|
|
|
|
await InsertRangeFailed(badDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task ClearAndInsertRange_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await ClearAndInsertRange(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task UpdateOrInsertRange_returns_success()
|
|
|
|
|
{
|
|
|
|
|
var dtoUpdate = dto.Adapt<ProcessMapPlanSlideDto>();
|
|
|
|
|
dtoUpdate.IdWell = 0;
|
|
|
|
|
dtoUpdate.Note = "nebuchadnezzar";
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoUpdate.DifferentialPressureMax++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
dtoUpdate.DifferentialPressure++;
|
|
|
|
|
dtoUpdate.FlowRate++;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoUpdate.FlowRateMax++;
|
|
|
|
|
dtoUpdate.RopMax++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
dtoUpdate.WeightOnBit++;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoUpdate.WeightOnBitMax++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
dtoUpdate.DepthStart++;
|
|
|
|
|
dtoUpdate.DepthEnd++;
|
|
|
|
|
dtoUpdate.Spring++;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoUpdate.Buckling++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
|
|
|
|
|
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanSlideDto>();
|
|
|
|
|
dtoInsert.Id = 0;
|
|
|
|
|
dtoInsert.Note = "nebuchad";
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoInsert.DifferentialPressureMax++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
dtoInsert.DifferentialPressure++;
|
|
|
|
|
dtoInsert.FlowRate++;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoInsert.FlowRateMax++;
|
|
|
|
|
dtoInsert.RopMax++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
dtoInsert.WeightOnBit++;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoInsert.WeightOnBitMax++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
dtoInsert.DepthStart++;
|
|
|
|
|
dtoInsert.DepthEnd++;
|
|
|
|
|
dtoUpdate.Spring++;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
dtoUpdate.Buckling++;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
|
|
|
|
|
await UpdateOrInsertRange(entity, dtoUpdate, dtoInsert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task DeleteRange_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await DeleteRange(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Clear_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await Clear(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task GetDatesChange_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await GetDatesChange(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Get_actual_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await Get(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Get_at_moment_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await GetAtMoment(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Get_by_updated_from_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await GetByUpdated(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Get_updated_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await GetUpdated(entity, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Parse_returns_success()
|
|
|
|
|
{
|
|
|
|
|
await Parse(dto.IdWell, "ProcessMapPlanSlideValid.xlsx", dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Parse_returns_success_for_result_with_warnings()
|
|
|
|
|
{
|
|
|
|
|
await ParseWithWarnings(dto.IdWell, "ProcessMapPlanSlideInvalid.xlsx");
|
|
|
|
|
}
|
|
|
|
|
}
|