forked from ddrilling/AsbCloudServer
Тесты нового алгоритма "Удержание в клиньях"
This commit is contained in:
parent
3176e89236
commit
47e9c9f2cd
69
AsbCloudWebApi.Tests/Builders/DetectableTelemetryBuilder.cs
Normal file
69
AsbCloudWebApi.Tests/Builders/DetectableTelemetryBuilder.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.Builders;
|
||||
|
||||
public class DetectableTelemetryBuilder
|
||||
{
|
||||
private DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
||||
private float wellDepth = 300;
|
||||
private float pressure = 15;
|
||||
private float hookWeight = 20;
|
||||
private float blockPosition = 20;
|
||||
private float bitDepth = 151;
|
||||
private float axialLoad = 19;
|
||||
|
||||
public DetectableTelemetryBuilder WithDateTime(DateTimeOffset newDateTime)
|
||||
{
|
||||
dateTime = newDateTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetryBuilder WithWellDepth(float newWllDepth)
|
||||
{
|
||||
wellDepth = newWllDepth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetryBuilder WithPressure(float newPressure)
|
||||
{
|
||||
pressure = newPressure;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetryBuilder WithHookWeight(float newHookWeight)
|
||||
{
|
||||
hookWeight = newHookWeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetryBuilder WithBlockPosition(float newBlockPosition)
|
||||
{
|
||||
blockPosition = newBlockPosition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetryBuilder WithBitDepth(float newBitDepth)
|
||||
{
|
||||
bitDepth = newBitDepth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetryBuilder WithAxialLoad(float newAxialLoad)
|
||||
{
|
||||
axialLoad = newAxialLoad;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DetectableTelemetry Build() =>
|
||||
new()
|
||||
{
|
||||
DateTime = dateTime,
|
||||
WellDepth = wellDepth,
|
||||
Pressure = pressure,
|
||||
HookWeight = hookWeight,
|
||||
BlockPosition = blockPosition,
|
||||
BitDepth = bitDepth,
|
||||
AxialLoad = axialLoad
|
||||
};
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
|
||||
using AsbCloudWebApi.Tests.Builders;
|
||||
using Xunit;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.Services.DetectedOperations.Detectors;
|
||||
|
||||
public class DetectorSlipsTimeTests
|
||||
{
|
||||
private const int IdSlipsTime = 5011;
|
||||
|
||||
private readonly DetectableTelemetryBuilder telemetryBuilder = new();
|
||||
|
||||
private readonly DetectorSlipsTime sut = new();
|
||||
|
||||
[Fact]
|
||||
public void DetectOperation_by_change_block_position_and_axial_load_less_hook_weight_is_success()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetryBuilder
|
||||
.Build();
|
||||
|
||||
var point1 = telemetryBuilder
|
||||
.WithBlockPosition(21)
|
||||
.Build();
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = sut.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.True(isDetectOperation);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(IdSlipsTime, result.Operation.IdCategory);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetectOperation_by_high_pressure_is_success()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetryBuilder
|
||||
.Build();
|
||||
|
||||
var point1 = telemetryBuilder
|
||||
.WithBlockPosition(21)
|
||||
.WithAxialLoad(30)
|
||||
.WithHookWeight(20)
|
||||
.WithPressure(23)
|
||||
.Build();
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = sut.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.True(isDetectOperation);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(IdSlipsTime, result.Operation.IdCategory);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateOperation_with_well_depth_before_150_meters_is_invalid()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetryBuilder
|
||||
.WithBitDepth(149)
|
||||
.Build();
|
||||
|
||||
var point1 = telemetryBuilder
|
||||
.WithBitDepth(149)
|
||||
.WithBlockPosition(21)
|
||||
.Build();
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = sut.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.False(isDetectOperation);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(IdSlipsTime, result.Operation.IdCategory);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateOperation_with_duration_more_30_minutes_is_invalid()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetryBuilder
|
||||
.Build();
|
||||
|
||||
var point1 = telemetryBuilder
|
||||
.WithDateTime(DateTimeOffset.UtcNow.AddMinutes(30))
|
||||
.WithBlockPosition(21)
|
||||
.Build();
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = sut.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.False(isDetectOperation);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(IdSlipsTime, result.Operation.IdCategory);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user