forked from ddrilling/AsbCloudServer
Интеграционный тест для получения ртк-отчета
This commit is contained in:
parent
6cf23e3e8c
commit
f570e82b41
@ -0,0 +1,16 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
|
using AsbCloudApp.Data.ProcessMaps.Report;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Refit;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.IntegrationTests.Clients;
|
||||||
|
|
||||||
|
public interface IProcessMapReportDrilling
|
||||||
|
{
|
||||||
|
private const string BaseRoute = "/api/well/{idWell}/ProcessMapReportDrilling";
|
||||||
|
|
||||||
|
[Get($"{BaseRoute}/report")]
|
||||||
|
Task<IApiResponse<IEnumerable<ProcessMapReportDataSaubStatDto>>> GetReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken);
|
||||||
|
}
|
@ -0,0 +1,237 @@
|
|||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudDb.Model.ProcessMapPlan;
|
||||||
|
using AsbCloudWebApi.IntegrationTests.Clients;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection;
|
||||||
|
using AsbCloudDb.Model.ProcessMaps;
|
||||||
|
using AsbCloudWebApi.IntegrationTests.Data;
|
||||||
|
using Refit;
|
||||||
|
using Xunit;
|
||||||
|
using AsbCloudApp.Data.ProcessMaps;
|
||||||
|
using AsbCloudDb.Model;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
|
||||||
|
|
||||||
|
public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly WellSectionType wellSection = new WellSectionType()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Caption = "Секция 1",
|
||||||
|
Order = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly WellOperationCategory wellOperationCategory = new WellOperationCategory()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
IdParent = null,
|
||||||
|
KeyValueName = "Name",
|
||||||
|
Name = "Name"
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly WellOperation wellOperation = new WellOperation()
|
||||||
|
{
|
||||||
|
CategoryInfo= "CategoryInfo",
|
||||||
|
Id = 10,
|
||||||
|
Comment = "Comment",
|
||||||
|
DateStart = DateTimeOffset.UtcNow,
|
||||||
|
DepthEnd = 1,
|
||||||
|
DepthStart = 0.6,
|
||||||
|
DurationHours = 10,
|
||||||
|
IdCategory = 1,
|
||||||
|
IdPlan = null,
|
||||||
|
IdType = 1,
|
||||||
|
IdUser = 1,
|
||||||
|
IdWell = 1,
|
||||||
|
IdWellSectionType = 1,
|
||||||
|
LastUpdateDate = DateTimeOffset.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly List<DataSaubStat> dataSaubStats = new List<DataSaubStat>()
|
||||||
|
{
|
||||||
|
|
||||||
|
new DataSaubStat()
|
||||||
|
{
|
||||||
|
AxialLoad = 0,
|
||||||
|
AxialLoadLimitMax = 10,
|
||||||
|
AxialLoadSp = 8,
|
||||||
|
BlockSpeedSp = 50.0,
|
||||||
|
DateEnd = DateTimeOffset.UtcNow,
|
||||||
|
DateStart = DateTimeOffset.UtcNow.AddDays(-1),
|
||||||
|
DepthEnd = 85.99299621582031,
|
||||||
|
DepthStart = 85.9260025024414,
|
||||||
|
EnabledSubsystems = 0,
|
||||||
|
Flow = 10,
|
||||||
|
HasOscillation = true,
|
||||||
|
Id = 1,
|
||||||
|
IdCategory = 1,
|
||||||
|
IdFeedRegulator = 0,
|
||||||
|
IdTelemetry = 1,
|
||||||
|
Pressure = 24,
|
||||||
|
PressureIdle = 0,
|
||||||
|
PressureSp = 40,
|
||||||
|
RotorSpeed = 11.3,
|
||||||
|
RotorTorque = 1,
|
||||||
|
RotorTorqueLimitMax = 26.5,
|
||||||
|
RotorTorqueSp = 5,
|
||||||
|
Speed = 80.3924560546875
|
||||||
|
},
|
||||||
|
new DataSaubStat()
|
||||||
|
{
|
||||||
|
AxialLoad = 2,
|
||||||
|
AxialLoadLimitMax = 10.0,
|
||||||
|
AxialLoadSp = 8,
|
||||||
|
BlockSpeedSp = 20,
|
||||||
|
DateEnd = DateTimeOffset.UtcNow.AddDays(-1),
|
||||||
|
DateStart = DateTimeOffset.UtcNow.AddDays(-2),
|
||||||
|
DepthEnd = 86.28099822998047,
|
||||||
|
DepthStart = 86.21900177001953,
|
||||||
|
EnabledSubsystems = 1,
|
||||||
|
Flow = 20,
|
||||||
|
HasOscillation = true,
|
||||||
|
Id = 2,
|
||||||
|
IdCategory = 1,
|
||||||
|
IdFeedRegulator = 1,
|
||||||
|
IdTelemetry = 1,
|
||||||
|
Pressure = 30,
|
||||||
|
PressureIdle = 20,
|
||||||
|
PressureSp = 40,
|
||||||
|
RotorSpeed = 11.251153300212916,
|
||||||
|
RotorTorque = 7,
|
||||||
|
RotorTorqueLimitMax = 26.5,
|
||||||
|
RotorTorqueSp = 9,
|
||||||
|
Speed = 74.395751953125
|
||||||
|
},
|
||||||
|
new DataSaubStat()
|
||||||
|
{
|
||||||
|
AxialLoad = 4,
|
||||||
|
AxialLoadLimitMax = 15.0,
|
||||||
|
AxialLoadSp = 8,
|
||||||
|
BlockSpeedSp = 110.0,
|
||||||
|
DateEnd = DateTimeOffset.UtcNow.AddDays(-2),
|
||||||
|
DateStart = DateTimeOffset.UtcNow.AddDays(-3),
|
||||||
|
DepthEnd = 106.7490005493164,
|
||||||
|
DepthStart = 106.47899627685547,
|
||||||
|
EnabledSubsystems = 1,
|
||||||
|
Flow = 30,
|
||||||
|
HasOscillation = true,
|
||||||
|
Id = 3,
|
||||||
|
IdCategory = 1,
|
||||||
|
IdFeedRegulator = 1,
|
||||||
|
IdTelemetry = 1,
|
||||||
|
Pressure = 36,
|
||||||
|
PressureIdle = 23.0,
|
||||||
|
PressureSp = 63.0,
|
||||||
|
RotorSpeed = 11.334207942999628,
|
||||||
|
RotorTorque = 14,
|
||||||
|
RotorTorqueLimitMax = 15.0,
|
||||||
|
RotorTorqueSp = 13,
|
||||||
|
Speed = 108.001708984375
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private readonly ProcessMapPlanDrilling entity = new ()
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
IdAuthor = 1,
|
||||||
|
IdEditor = null,
|
||||||
|
Creation = DateTimeOffset.UtcNow,
|
||||||
|
Obsolete = null,
|
||||||
|
IdState = AsbCloudDb.Model.ChangeLogAbstract.IdStateActual,
|
||||||
|
IdPrevious = null,
|
||||||
|
|
||||||
|
IdWell = 1,
|
||||||
|
IdWellSectionType = 1,
|
||||||
|
DepthStart = 0.5,
|
||||||
|
DepthEnd = 1.5,
|
||||||
|
|
||||||
|
IdMode = 1,
|
||||||
|
AxialLoadPlan = 2.718281,
|
||||||
|
AxialLoadLimitMax = 3.1415926,
|
||||||
|
DeltaPressurePlan = 4,
|
||||||
|
DeltaPressureLimitMax = 5,
|
||||||
|
TopDriveTorquePlan = 6,
|
||||||
|
TopDriveTorqueLimitMax = 7,
|
||||||
|
TopDriveSpeedPlan = 8,
|
||||||
|
TopDriveSpeedLimitMax = 9,
|
||||||
|
FlowPlan = 10,
|
||||||
|
FlowLimitMax = 11,
|
||||||
|
RopPlan = 12,
|
||||||
|
UsageSaub = 13,
|
||||||
|
UsageSpin = 14,
|
||||||
|
Comment = "это тестовая запись",
|
||||||
|
};
|
||||||
|
|
||||||
|
private IProcessMapReportDrilling client;
|
||||||
|
|
||||||
|
public ProcessMapReportDrillingControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
|
{
|
||||||
|
dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
|
||||||
|
client = factory.GetAuthorizedHttpClient<IProcessMapReportDrilling>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Get_rtk_report_returns_success()
|
||||||
|
{
|
||||||
|
//arrange
|
||||||
|
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
||||||
|
dbset.Add(entity);
|
||||||
|
entity.Id = 1;
|
||||||
|
dbset.Add(entity);
|
||||||
|
entity.Id = 2;
|
||||||
|
dbset.Add(entity);
|
||||||
|
|
||||||
|
var dbSetWellOperationCategory = dbContext.Set<WellOperationCategory>();
|
||||||
|
dbSetWellOperationCategory.Add(wellOperationCategory);
|
||||||
|
|
||||||
|
var dbSetWellOperation = dbContext.Set<WellOperation>();
|
||||||
|
dbSetWellOperation.Add(wellOperation);
|
||||||
|
|
||||||
|
var dbSetDataSaubStat = dbContext.Set<DataSaubStat>();
|
||||||
|
dbSetDataSaubStat.AddRange(dataSaubStats);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
//act
|
||||||
|
var request = new DataSaubStatRequest();
|
||||||
|
var response = await client.GetReportAsync(1, request, CancellationToken.None);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
Assert.NotNull(response.Content);
|
||||||
|
Assert.Equal(dataSaubStats.Count() - 1, response.Content.Count());
|
||||||
|
|
||||||
|
//act
|
||||||
|
request = new DataSaubStatRequest() {
|
||||||
|
DeltaAxialLoad = 5,
|
||||||
|
DeltaPressure = 15,
|
||||||
|
DeltaRotorTorque = 10
|
||||||
|
};
|
||||||
|
response = await client.GetReportAsync(1, request, CancellationToken.None);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
Assert.NotNull(response.Content);
|
||||||
|
Assert.Equal(1, response.Content.Count());
|
||||||
|
|
||||||
|
//act
|
||||||
|
request = new DataSaubStatRequest()
|
||||||
|
{
|
||||||
|
DeltaAxialLoad = 15,
|
||||||
|
DeltaPressure = 25,
|
||||||
|
DeltaRotorTorque = 20
|
||||||
|
};
|
||||||
|
response = await client.GetReportAsync(1, request, CancellationToken.None);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user