forked from ddrilling/AsbCloudServer
86 lines
2.1 KiB
C#
86 lines
2.1 KiB
C#
using System;
|
|
using AsbCloudInfrastructure.Services.DetectOperations;
|
|
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
|
|
using Xunit;
|
|
|
|
namespace AsbCloudWebApi.Tests.Services.DetectedOperations.Detectors;
|
|
|
|
public class DetectorSlipsTimeTests
|
|
{
|
|
private const int IdSlipsTime = 5011;
|
|
|
|
private readonly DetectableTelemetry telemetry = new() {
|
|
WellDepth = 300,
|
|
Pressure = 15,
|
|
HookWeight = 20,
|
|
BlockPosition = 20,
|
|
BitDepth = 151,
|
|
AxialLoad = 19,
|
|
};
|
|
|
|
private readonly DetectorSlipsTime sut = new();
|
|
|
|
[Fact]
|
|
public void DetectOperation_by_change_block_position_and_axial_load_less_hook_weight_is_success()
|
|
{
|
|
//arrange
|
|
var point0 = telemetry.Copy();
|
|
|
|
var point1 = telemetry.Copy();
|
|
point1.BlockPosition = 21;
|
|
|
|
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 = telemetry.Copy();
|
|
|
|
var point1 = telemetry.Copy();
|
|
point1.BlockPosition = 21;
|
|
point1.AxialLoad = 30;
|
|
point1.HookWeight = 20;
|
|
point1.Pressure = 23;
|
|
|
|
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_duration_more_30_minutes_is_invalid()
|
|
{
|
|
//arrange
|
|
var point0 = telemetry.Copy();
|
|
|
|
var point1 = telemetry.Copy();
|
|
point1.BlockPosition = 21;
|
|
point1.DateTime = DateTimeOffset.UtcNow.AddMinutes(30);
|
|
|
|
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);
|
|
}
|
|
} |