forked from ddrilling/AsbCloudServer
#7887519 test
This commit is contained in:
parent
454566dc2e
commit
17cf2c6573
@ -3,7 +3,6 @@ using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudDb.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -22,37 +21,30 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
public async Task<IEnumerable<LimitingParameterDataDto>> GetStatOrDefaultAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var query = BuildQuery(request, wellDto);
|
||||
var query = BuildQuery(request, wellDto);
|
||||
|
||||
if (query is null)
|
||||
return Enumerable.Empty<LimitingParameterDataDto>();
|
||||
|
||||
var data = (await query.ToListAsync(token))
|
||||
.Select(x => new LimitingParameterDataDto
|
||||
{
|
||||
IdWell = wellDto.Id,
|
||||
IdTelemetry = x.IdTelemetry,
|
||||
IdFeedRegulator = x.IdFeedRegulator,
|
||||
DateStart = x.DateStart,
|
||||
DateEnd = x.DateEnd,
|
||||
DepthStart = x.DepthStart,
|
||||
DepthEnd = x.DepthEnd
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (query is null)
|
||||
return Enumerable.Empty<LimitingParameterDataDto>();
|
||||
}
|
||||
|
||||
var data = (await query.ToListAsync(token))
|
||||
.Select(x => new LimitingParameterDataDto
|
||||
{
|
||||
IdWell = wellDto.Id,
|
||||
IdTelemetry = x.IdTelemetry,
|
||||
IdFeedRegulator = x.IdFeedRegulator,
|
||||
DateStart = x.DateStart,
|
||||
DateEnd = x.DateEnd,
|
||||
DepthStart = x.DepthStart,
|
||||
DepthEnd = x.DepthEnd
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private IQueryable<LimitingParameter> BuildQuery(LimitingParameterRequest request, WellDto wellDto)
|
||||
{
|
||||
var query = context.LimitingParameter
|
||||
//.OrderBy(x => x.Id)
|
||||
.OrderBy(x => x.Id)
|
||||
.Where(x => x.IdTelemetry == wellDto.IdTelemetry)
|
||||
.AsNoTracking();
|
||||
|
||||
|
@ -7,9 +7,7 @@ using AsbCloudInfrastructure.Repository;
|
||||
using AsbCloudInfrastructure.Services;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
@ -88,6 +86,9 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
||||
{
|
||||
var data = await limitingParameterService.GetStatOrDefaultAsync(limitingParameterRequest, CancellationToken.None);
|
||||
Assert.NotNull(data);
|
||||
Assert.Single(data);
|
||||
Assert.Equal(1275, data.First().Depth);
|
||||
Assert.Equal(10080, data.First().TotalMinutes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user