From 4f468ed8ba40cd385b5c27c52b969e7eaeb5b5b1 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Mon, 5 Feb 2024 13:23:29 +0500 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D1=8B=20=D0=B4=D0=BB=D1=8F=20dataSaubStat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSaubStat/DataSaubStatServiceTests.cs | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 AsbCloudWebApi.Tests/Services/DataSaubStat/DataSaubStatServiceTests.cs diff --git a/AsbCloudWebApi.Tests/Services/DataSaubStat/DataSaubStatServiceTests.cs b/AsbCloudWebApi.Tests/Services/DataSaubStat/DataSaubStatServiceTests.cs new file mode 100644 index 00000000..18164509 --- /dev/null +++ b/AsbCloudWebApi.Tests/Services/DataSaubStat/DataSaubStatServiceTests.cs @@ -0,0 +1,71 @@ +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 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(); + } + + [Fact] + public async Task GetAsync_ReturnsDataSaubStat() + { + dataSaubStatRepository.GetLastDatesAsync(Arg.Any(), Arg.Any()).Returns(stats); + Assert.Equal(2, stats.Count()); + } + + [Fact] + public async Task InsertRangeAsync_Returns_statusOk() + { + var result = await dataSaubStatRepository.InsertRangeAsync(stats, Arg.Any()); + Assert.Equal(1, result); + } +} \ No newline at end of file