forked from ddrilling/AsbCloudServer
fix tests.
This commit is contained in:
parent
d6b5a9507b
commit
f2f16221c8
@ -10,6 +10,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
|||||||
const double minRotorSpeed = 5; //об/мин
|
const double minRotorSpeed = 5; //об/мин
|
||||||
const double ticksPerHour = 60 * 60 * 10_000_000d;
|
const double ticksPerHour = 60 * 60 * 10_000_000d;
|
||||||
const double minPressure = 25;
|
const double minPressure = 25;
|
||||||
|
const double minDeltaDepth = 0.02;
|
||||||
|
|
||||||
public DetectorDrillingRotor() : base(2)
|
public DetectorDrillingRotor() : base(2)
|
||||||
{
|
{
|
||||||
@ -22,7 +23,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
|||||||
var firstItem = telemetry[position];
|
var firstItem = telemetry[position];
|
||||||
var deltaDepth = firstItem.WellDepth - firstItem.BitDepth;
|
var deltaDepth = firstItem.WellDepth - firstItem.BitDepth;
|
||||||
if (deltaDepth is not null &&
|
if (deltaDepth is not null &&
|
||||||
System.Math.Abs((float)deltaDepth) > 1d)
|
System.Math.Abs((float)deltaDepth) > minDeltaDepth)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(firstItem.RotorSpeed > minRotorSpeed)
|
if(firstItem.RotorSpeed > minRotorSpeed)
|
||||||
|
@ -10,6 +10,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
|||||||
const double minRotorSpeed = 5; //об/мин
|
const double minRotorSpeed = 5; //об/мин
|
||||||
const double ticksPerHour = 60 * 60 * 10_000_000d;
|
const double ticksPerHour = 60 * 60 * 10_000_000d;
|
||||||
const double minPressure = 25;
|
const double minPressure = 25;
|
||||||
|
const double minDeltaDepth = 0.02;
|
||||||
|
|
||||||
public DetectorDrillingSlide() : base(3)
|
public DetectorDrillingSlide() : base(3)
|
||||||
{
|
{
|
||||||
@ -21,7 +22,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
|||||||
var firstItem = telemetry[position];
|
var firstItem = telemetry[position];
|
||||||
var deltaDepth = firstItem.WellDepth - firstItem.BitDepth;
|
var deltaDepth = firstItem.WellDepth - firstItem.BitDepth;
|
||||||
if (deltaDepth is not null &&
|
if (deltaDepth is not null &&
|
||||||
System.Math.Abs((float)deltaDepth) > 1d)
|
System.Math.Abs((float)deltaDepth) > minDeltaDepth)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(firstItem.RotorSpeed < minRotorSpeed)
|
if(firstItem.RotorSpeed < minRotorSpeed)
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.6" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||||
<PackageReference Include="Moq" Version="4.18.1" />
|
<PackageReference Include="Moq" Version="4.18.1" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services;
|
using AsbCloudInfrastructure.Services;
|
||||||
@ -19,6 +20,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
private readonly AsbCloudDbContext context;
|
private readonly AsbCloudDbContext context;
|
||||||
private readonly CacheDb cacheDb;
|
private readonly CacheDb cacheDb;
|
||||||
private readonly DetectedOperationService service;
|
private readonly DetectedOperationService service;
|
||||||
|
private readonly DetectedOperationRequest request;
|
||||||
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
|
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
|
||||||
private Cluster cluster = new Cluster { Id = 1, Caption = "Кластер 1", IdDeposit = 1, Timezone = new SimpleTimezone() };
|
private Cluster cluster = new Cluster { Id = 1, Caption = "Кластер 1", IdDeposit = 1, Timezone = new SimpleTimezone() };
|
||||||
private WellDto wellDto = new WellDto
|
private WellDto wellDto = new WellDto
|
||||||
@ -126,6 +128,11 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
var scheduleService = new ScheduleService(context, wellServiceMock.Object);
|
var scheduleService = new ScheduleService(context, wellServiceMock.Object);
|
||||||
|
|
||||||
service = new DetectedOperationService(context, wellServiceMock.Object, operationValueService, scheduleService);
|
service = new DetectedOperationService(context, wellServiceMock.Object, operationValueService, scheduleService);
|
||||||
|
request = new DetectedOperationRequest
|
||||||
|
{
|
||||||
|
IdWell = 1,
|
||||||
|
IdCategory = 1
|
||||||
|
};
|
||||||
AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
|
AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,39 +144,39 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task Count_grouping_by_driller()
|
public async Task Count_grouping_by_driller()
|
||||||
{
|
{
|
||||||
var list = await service.GetAsync(1, null, CancellationToken.None);
|
var list = await service.GetAsync(request, CancellationToken.None);
|
||||||
Assert.Equal(2, list.Stats.First().Count);
|
Assert.Equal(2, list.Stats.First().Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task AvgVal_grouping_by_driller()
|
public async Task AvgVal_grouping_by_driller()
|
||||||
{
|
{
|
||||||
var list = await service.GetAsync(1, null, CancellationToken.None);
|
var list = await service.GetAsync(request, CancellationToken.None);
|
||||||
Assert.Equal(30, list.Stats.First().AverageValue);
|
Assert.Equal(30, list.Stats.First().AverageValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task AvgTargetVal_grouping_by_driller()
|
public async Task AvgTargetVal_grouping_by_driller()
|
||||||
{
|
{
|
||||||
var list = await service.GetAsync(1, null, CancellationToken.None);
|
var list = await service.GetAsync(request, CancellationToken.None);
|
||||||
Assert.Equal(100, list.Stats.First().AverageTargetValue);
|
Assert.Equal(100, list.Stats.First().AverageTargetValue);
|
||||||
}
|
}
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Loss_grouping_by_driller()
|
public async Task Loss_grouping_by_driller()
|
||||||
{
|
{
|
||||||
var list = await service.GetAsync(1, null, CancellationToken.None);
|
var list = await service.GetAsync(request, CancellationToken.None);
|
||||||
Assert.Equal(0, list.Stats.First().Loss);
|
Assert.Equal(0, list.Stats.First().Loss);
|
||||||
}
|
}
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Efficiency_grouping_by_driller()
|
public async Task Efficiency_grouping_by_driller()
|
||||||
{
|
{
|
||||||
var list = await service.GetAsync(1, null, CancellationToken.None);
|
var list = await service.GetAsync(request, CancellationToken.None);
|
||||||
Assert.Equal(100, list.Stats.First().Efficiency);
|
Assert.Equal(100, list.Stats.First().Efficiency);
|
||||||
}
|
}
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GroupCount_grouping_by_driller()
|
public async Task GroupCount_grouping_by_driller()
|
||||||
{
|
{
|
||||||
var list = await service.GetAsync(1, null, CancellationToken.None);
|
var list = await service.GetAsync(request, CancellationToken.None);
|
||||||
Assert.Equal(1, list.Stats.Count());
|
Assert.Equal(1, list.Stats.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Tests
|
namespace AsbCloudWebApi.Tests
|
||||||
{
|
{
|
||||||
@ -8,10 +9,13 @@ namespace AsbCloudWebApi.Tests
|
|||||||
public static AsbCloudDbContext MakeTestContext()
|
public static AsbCloudDbContext MakeTestContext()
|
||||||
{
|
{
|
||||||
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
||||||
|
//.UseInMemoryDatabase(System.Guid.NewGuid().ToString())
|
||||||
|
//.ConfigureWarnings(configBuilder =>
|
||||||
|
// configBuilder.Ignore(InMemoryEventId.TransactionIgnoredWarning))
|
||||||
.UseNpgsql("Host=localhost;Database=tests;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True")
|
.UseNpgsql("Host=localhost;Database=tests;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True")
|
||||||
.Options;
|
.Options;
|
||||||
var context = new AsbCloudDbContext(options);
|
var context = new AsbCloudDbContext(options);
|
||||||
context.Database.EnsureDeleted();
|
//context.Database.EnsureDeleted();
|
||||||
context.Database.EnsureCreated();
|
context.Database.EnsureCreated();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user