DD.WellWorkover.Cloud/AsbCloudWebApi.IntegrationTests/Controllers/ProcessMapPlan/ProcessMapPlanRotorControllerTest.cs

210 lines
5.4 KiB
C#
Raw Normal View History

using AsbCloudApp.Data.ProcessMaps;
using AsbCloudDb.Model.ProcessMaps;
using DocumentFormat.OpenXml.Drawing.Charts;
using Mapster;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
public class ProcessMapPlanRotorControllerTest : ProcessMapPlanBaseControllerTest<AsbCloudDb.Model.ProcessMaps.ProcessMapPlanRotor, ProcessMapPlanRotorDto>
{
private readonly ProcessMapPlanRotorDto dto = new ProcessMapPlanRotorDto()
{
IdWell = 1,
DepthStart = 1,
DepthEnd = 2,
2024-06-29 20:46:11 +05:00
RopMax = 3,
PressureMax = 4,
DifferentialPressure = 5,
2024-06-29 20:46:11 +05:00
DifferentialPressureMax = 6,
WeightOnBit = 7,
2024-06-29 20:46:11 +05:00
WeightOnBitMax = 8,
TopDriveTorque = 9,
2024-06-29 20:46:11 +05:00
TopDriveTorqueMax = 10,
Rpm = 11,
RpmMax = 12,
FlowRate = 13,
2024-06-29 20:46:11 +05:00
FlowRateMax = 14,
Note = "15",
Id = 0,
IdWellSectionType = 1,
};
private readonly ProcessMapPlanRotor entity = new ProcessMapPlanRotor()
{
IdWell = 1,
DepthEnd = 10,
DepthStart = 2,
DifferentialPressure = 3,
2024-06-29 20:46:11 +05:00
DifferentialPressureMax = 4,
FlowRate = 5,
2024-06-29 20:46:11 +05:00
FlowRateMax = 6,
Id = 0,
IdWellSectionType = 1,
Note = "1",
PressureLimitMax = 2,
2024-06-29 20:46:11 +05:00
Rpm = 3,
RpmMax = 4,
RopMax = 5,
TopDriveTorque = 6,
2024-06-29 20:46:11 +05:00
TopDriveTorqueMax = 7,
WeightOnBit = 8,
2024-06-29 20:46:11 +05:00
WeightOnBitMax = 9,
IdAuthor = 1,
IdEditor = 1,
Creation = DateTimeOffset.UtcNow
};
public ProcessMapPlanRotorControllerTest(WebAppFactoryFixture factory) : base(factory, "ProcessMapPlanRotor")
{
}
protected override ProcessMapPlanRotor? GetByWellId()
{
var entity = dbContext
.Set<ProcessMapPlanRotor>()
.Where(p => p.WeightOnBit == dto.WeightOnBit)
2024-06-29 20:46:11 +05:00
.Where(p => p.WeightOnBitMax == dto.WeightOnBitMax)
.Where(p => p.Note == dto.Note)
.FirstOrDefault(p => p.IdWell == dto.IdWell);
return entity;
}
protected override ProcessMapPlanRotor GetByNote(
DbSet<ProcessMapPlanRotor> dbSet,
ProcessMapPlanRotorDto dto)
{
var entity = dbSet.First(p => p.Note == dto.Note);
return entity;
}
protected override ProcessMapPlanRotorDto GetByNote(
IEnumerable<ProcessMapPlanRotorDto> dtos,
ProcessMapPlanRotorDto 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<ProcessMapPlanRotorDto>();
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<ProcessMapPlanRotorDto>();
dtoUpdate.IdWell = 0;
dtoUpdate.Note = "nebuchadnezzar";
2024-06-29 20:46:11 +05:00
dtoUpdate.DifferentialPressureMax++;
dtoUpdate.DifferentialPressure++;
dtoUpdate.FlowRate++;
2024-06-29 20:46:11 +05:00
dtoUpdate.FlowRateMax++;
dtoUpdate.RopMax++;
dtoUpdate.WeightOnBit++;
2024-06-29 20:46:11 +05:00
dtoUpdate.WeightOnBitMax++;
dtoUpdate.DepthStart++;
dtoUpdate.DepthEnd++;
2024-06-29 20:46:11 +05:00
dtoUpdate.Rpm++;
dtoUpdate.RpmMax++;
dtoUpdate.TopDriveTorque++;
2024-06-29 20:46:11 +05:00
dtoUpdate.TopDriveTorqueMax++;
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanRotorDto>();
dtoInsert.Id = 0;
dtoInsert.Note = "nebuchad";
2024-06-29 20:46:11 +05:00
dtoInsert.DifferentialPressureMax++;
dtoInsert.DifferentialPressure++;
dtoInsert.FlowRate++;
2024-06-29 20:46:11 +05:00
dtoInsert.FlowRateMax++;
dtoInsert.RopMax++;
dtoInsert.WeightOnBit++;
2024-06-29 20:46:11 +05:00
dtoInsert.WeightOnBitMax++;
dtoInsert.DepthStart++;
dtoInsert.DepthEnd++;
2024-06-29 20:46:11 +05:00
dtoInsert.Rpm++;
dtoInsert.RpmMax++;
dtoInsert.TopDriveTorque++;
2024-06-29 20:46:11 +05:00
dtoInsert.TopDriveTorqueMax++;
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, "ProcessMapPlanRotorValid.xlsx", dto);
}
[Fact]
public async Task Parse_returns_success_for_result_with_warnings()
{
await ParseWithWarnings(dto.IdWell, "ProcessMapPlanRotorInvalid.xlsx");
}
}