DD.WellWorkover.Cloud/AsbCloudInfrastructure.Tests/Services/DetectedOperations/Detectors/DetectorConditioning.cs
2024-08-19 10:57:31 +05:00

92 lines
2.9 KiB
C#

using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.DetectOperations;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
using System;
using Xunit;
namespace AsbCloudInfrastructure.Tests.Services.DetectedOperations.Detectors;
/// <summary>
/// Тестирование автоопределения операции "Проработка"
/// </summary>
public class DetectorConditioningTests : DetectorFlashing
{
private readonly DetectorConditioning detector = new();
/// <summary>
/// Операция, попадающая под автоопределение операции промывки
/// </summary>
private readonly DetectableTelemetry telemetry = new()
{
Pressure = 21,
RotorSpeed = 9,
WellDepth = 152,
BitDepth = 151,
DateTime = DateTimeOffset.Now,
};
[Fact]
public void DetectOperation_find_startOperation_notFind_endOperation()
{
//arrange
var point0 = telemetry.Copy();
var point1 = telemetry.Copy();
point1.DateTime = point0.DateTime.AddMinutes(3);
var telemetries = new[] { point0, point1 };
//act
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
//assert
Assert.True(isDetectOperation);
Assert.NotNull(result);
Assert.Equal(WellOperationCategory.IdConditioning, result.Operation.IdCategory);
Assert.Equal(IdReasonOfEnd_NotDetected, result.Operation.ExtraData["IdReasonOfEnd"]);
}
[Fact]
public void DetectOperation_with_BitDepth_LE_150_is_fail()
{
//arrange
var point0 = telemetry.Copy();
point0.BitDepth = 150;
var point1 = telemetry.Copy();
var telemetries = new[] { point0, point1 };
//act
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
//assert
Assert.False(isDetectOperation);
Assert.NotNull(result);
Assert.Equal(WellOperationCategory.IdConditioning, result.Operation.IdCategory);
Assert.Equal(IdReasonOfEnd_NotDetected, result.Operation.ExtraData["IdReasonOfEnd"]);
}
[Fact]
public void DetectOperations_Begin_And_End_by_Pressure_Less_10_is_success()
{
//arrange
var point0 = telemetry.Copy();
var point1 = telemetry.Copy();
point1.Pressure = 9;
var telemetries = new[] { point0, point1 };
//act
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
//assert
Assert.False(isDetectOperation);
Assert.NotNull(result);
Assert.Equal(WellOperationCategory.IdConditioning, result.Operation.IdCategory);
Assert.Equal(IdReasonOfEnd_PressureIsLo, result.Operation.ExtraData["IdReasonOfEnd"]);
}
}