forked from ddrilling/AsbCloudServer
Деление одного теста с получением ртк-отчета на несколько
This commit is contained in:
parent
58729077fa
commit
2ece8cdb9f
@ -15,6 +15,6 @@ public interface IProcessMapReportDrilling
|
|||||||
Task<IApiResponse<IEnumerable<ProcessMapReportDataSaubStatDto>>> GetReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken);
|
Task<IApiResponse<IEnumerable<ProcessMapReportDataSaubStatDto>>> GetReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken);
|
||||||
|
|
||||||
[Get($"{BaseRoute}/report/export")]
|
[Get($"{BaseRoute}/report/export")]
|
||||||
Task<IApiResponse<IActionResult>> ExportReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken);
|
Task<IApiResponse<PhysicalFileResult>> ExportReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,22 @@
|
|||||||
using AsbCloudApp.Requests;
|
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;
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudDb.Model.ProcessMaps;
|
||||||
|
using AsbCloudWebApi.IntegrationTests.Clients;
|
||||||
|
using Org.BouncyCastle.Asn1.Ocsp;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
|
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
|
||||||
|
|
||||||
public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
public class ProcessMapReportDrillingControllerTest : BaseIntegrationTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly WellSectionType wellSection = new WellSectionType()
|
private readonly WellSectionType wellSection = new WellSectionType()
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
Caption = "Секция 1",
|
Caption = "Секция 1",
|
||||||
Order = 1
|
Order = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly WellOperationCategory wellOperationCategory = new WellOperationCategory()
|
private readonly WellOperationCategory wellOperationCategory = new WellOperationCategory()
|
||||||
@ -29,12 +24,12 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
Id = 1,
|
Id = 1,
|
||||||
IdParent = null,
|
IdParent = null,
|
||||||
KeyValueName = "Name",
|
KeyValueName = "Name",
|
||||||
Name = "Name"
|
Name = "Name"
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly WellOperation wellOperation = new WellOperation()
|
private readonly WellOperation wellOperation = new WellOperation()
|
||||||
{
|
{
|
||||||
CategoryInfo= "CategoryInfo",
|
CategoryInfo = "CategoryInfo",
|
||||||
Id = 10,
|
Id = 10,
|
||||||
Comment = "Comment",
|
Comment = "Comment",
|
||||||
DateStart = DateTimeOffset.UtcNow,
|
DateStart = DateTimeOffset.UtcNow,
|
||||||
@ -59,8 +54,8 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
AxialLoadLimitMax = 10,
|
AxialLoadLimitMax = 10,
|
||||||
AxialLoadSp = 8,
|
AxialLoadSp = 8,
|
||||||
BlockSpeedSp = 50.0,
|
BlockSpeedSp = 50.0,
|
||||||
DateEnd = DateTimeOffset.UtcNow,
|
DateEnd = DateTimeOffset.UtcNow.AddMinutes(40),
|
||||||
DateStart = DateTimeOffset.UtcNow.AddDays(-1),
|
DateStart = DateTimeOffset.UtcNow.AddMinutes(30),
|
||||||
DepthEnd = 85.99299621582031,
|
DepthEnd = 85.99299621582031,
|
||||||
DepthStart = 85.9260025024414,
|
DepthStart = 85.9260025024414,
|
||||||
EnabledSubsystems = 0,
|
EnabledSubsystems = 0,
|
||||||
@ -85,8 +80,8 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
AxialLoadLimitMax = 10.0,
|
AxialLoadLimitMax = 10.0,
|
||||||
AxialLoadSp = 8,
|
AxialLoadSp = 8,
|
||||||
BlockSpeedSp = 20,
|
BlockSpeedSp = 20,
|
||||||
DateEnd = DateTimeOffset.UtcNow.AddDays(-1),
|
DateEnd = DateTimeOffset.UtcNow.AddMinutes(30),
|
||||||
DateStart = DateTimeOffset.UtcNow.AddDays(-2),
|
DateStart = DateTimeOffset.UtcNow.AddMinutes(20),
|
||||||
DepthEnd = 86.28099822998047,
|
DepthEnd = 86.28099822998047,
|
||||||
DepthStart = 86.21900177001953,
|
DepthStart = 86.21900177001953,
|
||||||
EnabledSubsystems = 1,
|
EnabledSubsystems = 1,
|
||||||
@ -111,8 +106,8 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
AxialLoadLimitMax = 15.0,
|
AxialLoadLimitMax = 15.0,
|
||||||
AxialLoadSp = 8,
|
AxialLoadSp = 8,
|
||||||
BlockSpeedSp = 110.0,
|
BlockSpeedSp = 110.0,
|
||||||
DateEnd = DateTimeOffset.UtcNow.AddDays(-2),
|
DateEnd = DateTimeOffset.UtcNow.AddMinutes(20),
|
||||||
DateStart = DateTimeOffset.UtcNow.AddDays(-3),
|
DateStart = DateTimeOffset.UtcNow.AddMinutes(10),
|
||||||
DepthEnd = 106.7490005493164,
|
DepthEnd = 106.7490005493164,
|
||||||
DepthStart = 106.47899627685547,
|
DepthStart = 106.47899627685547,
|
||||||
EnabledSubsystems = 1,
|
EnabledSubsystems = 1,
|
||||||
@ -136,7 +131,7 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private readonly ProcessMapPlanDrilling entity = new ()
|
private readonly ProcessMapPlanDrilling entity = new()
|
||||||
{
|
{
|
||||||
Id = 0,
|
Id = 0,
|
||||||
IdAuthor = 1,
|
IdAuthor = 1,
|
||||||
@ -172,18 +167,15 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
|
|
||||||
public ProcessMapReportDrillingControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public ProcessMapReportDrillingControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
client = factory.GetAuthorizedHttpClient<IProcessMapReportDrilling>();
|
client = factory.GetAuthorizedHttpClient<IProcessMapReportDrilling>(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Get_rtk_report_returns_success()
|
public async Task Get_rtk_report_by_default_request_returns_success()
|
||||||
{
|
{
|
||||||
//clear
|
|
||||||
dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
|
|
||||||
|
|
||||||
//arrange
|
//arrange
|
||||||
|
dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
|
||||||
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
||||||
dbset.Add(entity);
|
dbset.Add(entity);
|
||||||
entity.Id = 1;
|
entity.Id = 1;
|
||||||
@ -210,28 +202,77 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.Equal(dataSaubStats.Count() - 1, response.Content.Count());
|
Assert.Equal(dataSaubStats.Count() - 1, response.Content.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Get_rtk_report_by_parametrize_request_returns_success()
|
||||||
|
{
|
||||||
|
//arrange
|
||||||
|
dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
|
||||||
|
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
|
//act
|
||||||
request = new DataSaubStatRequest() {
|
var request = new DataSaubStatRequest()
|
||||||
|
{
|
||||||
DeltaAxialLoad = 5,
|
DeltaAxialLoad = 5,
|
||||||
DeltaPressure = 15,
|
DeltaPressure = 15,
|
||||||
DeltaRotorTorque = 10
|
DeltaRotorTorque = 10
|
||||||
};
|
};
|
||||||
response = await client.GetReportAsync(1, request, CancellationToken.None);
|
var response = await client.GetReportAsync(1, request, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.Equal(1, response.Content.Count());
|
Assert.Equal(1, response.Content.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Get_rtk_report_returns_BadRequest()
|
||||||
|
{
|
||||||
|
//arrange
|
||||||
|
dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
|
||||||
|
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
|
//act
|
||||||
request = new DataSaubStatRequest()
|
var request = new DataSaubStatRequest()
|
||||||
{
|
{
|
||||||
DeltaAxialLoad = 15,
|
DeltaAxialLoad = 15,
|
||||||
DeltaPressure = 25,
|
DeltaPressure = 25,
|
||||||
DeltaRotorTorque = 20
|
DeltaRotorTorque = 20
|
||||||
};
|
};
|
||||||
response = await client.GetReportAsync(1, request, CancellationToken.None);
|
var response = await client.GetReportAsync(1, request, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
@ -268,6 +309,7 @@ public class ProcessMapReportDrillingControllerTest: BaseIntegrationTest
|
|||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.Equal("application/octet-stream", response.ContentHeaders?.ContentType?.MediaType);
|
||||||
|
Assert.True(response.ContentHeaders?.ContentLength > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user