forked from ddrilling/AsbCloudServer
71 lines
2.0 KiB
C#
71 lines
2.0 KiB
C#
|
using AsbCloudApp.Data;
|
||
|
using AsbCloudApp.Data.ProcessMaps;
|
||
|
using AsbCloudApp.Repositories;
|
||
|
using NSubstitute;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Threading;
|
||
|
using System.Threading.Tasks;
|
||
|
using Xunit;
|
||
|
|
||
|
namespace AsbCloudWebApi.Tests.Services.ProcessMaps;
|
||
|
|
||
|
public class DataSaubStatServiceTests
|
||
|
{
|
||
|
private readonly IEnumerable<DataSaubStatDto> stats = new DataSaubStatDto[]
|
||
|
{
|
||
|
new()
|
||
|
{
|
||
|
IdTelemetry = 1,
|
||
|
DateEnd = DateTimeOffset.UtcNow.AddDays(-10),
|
||
|
DateStart = DateTimeOffset.UtcNow.AddDays(-11),
|
||
|
AxialLoad = 10.0,
|
||
|
AxialLoadLimitMax = 10.0,
|
||
|
AxialLoadSp = 10.0,
|
||
|
BlockSpeedSp = 1000,
|
||
|
DepthEnd = 10.0,
|
||
|
DepthStart = 5.0,
|
||
|
EnabledSubsystems = 1,
|
||
|
Flow = 10.0,
|
||
|
HasOscillation = true,
|
||
|
Id = 1,
|
||
|
IdCategory = 2,
|
||
|
IdFeedRegulator = 1,
|
||
|
Pressure = 10.0,
|
||
|
PressureIdle = 10.0,
|
||
|
PressureSp = 10.0,
|
||
|
RotorSpeed = 10.0,
|
||
|
RotorTorque = 10.0,
|
||
|
RotorTorqueSp = 10.0,
|
||
|
RotorTorqueLimitMax = 10.0,
|
||
|
Speed = 10.0,
|
||
|
Telemetry = new TelemetryDto(){
|
||
|
Id = 1,
|
||
|
},
|
||
|
OperationCategory = new WellOperationCategoryDto(){
|
||
|
Id = 2,
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
private readonly IDataSaubStatRepository dataSaubStatRepository;
|
||
|
|
||
|
public DataSaubStatServiceTests()
|
||
|
{
|
||
|
dataSaubStatRepository = Substitute.For<IDataSaubStatRepository>();
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public async Task GetAsync_ReturnsDataSaubStat()
|
||
|
{
|
||
|
dataSaubStatRepository.GetLastDatesAsync(Arg.Any<int[]>(), Arg.Any<CancellationToken>()).Returns(stats);
|
||
|
Assert.Equal(2, stats.Count());
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public async Task InsertRangeAsync_Returns_statusOk()
|
||
|
{
|
||
|
var result = await dataSaubStatRepository.InsertRangeAsync(stats, Arg.Any<CancellationToken>());
|
||
|
Assert.Equal(1, result);
|
||
|
}
|
||
|
}
|