forked from ddrilling/AsbCloudServer
68 lines
1.7 KiB
C#
68 lines
1.7 KiB
C#
using System.Net;
|
|
using AsbCloudApp.Requests;
|
|
using AsbCloudDb.Model.GTR;
|
|
using AsbCloudWebApi.IntegrationTests.Clients;
|
|
using Xunit;
|
|
|
|
namespace AsbCloudWebApi.IntegrationTests.Controllers;
|
|
|
|
public class GtrControllerTests : BaseIntegrationTest
|
|
{
|
|
private readonly IGtrWitsClient client;
|
|
|
|
public GtrControllerTests(WebAppFactoryFixture factory)
|
|
: base(factory)
|
|
{
|
|
client = factory.GetAuthorizedHttpClient<IGtrWitsClient>(string.Empty);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetAll_returns_success()
|
|
{
|
|
//arrange
|
|
var well = dbContext.Wells.First();
|
|
|
|
var witsItems = CreateWitsItems(well.IdTelemetry!.Value);
|
|
dbContext.WitsItemFloat.AddRange(witsItems);
|
|
await dbContext.SaveChangesAsync();
|
|
|
|
var request = new GtrRequest();
|
|
|
|
//act
|
|
var response = await client.GetAllAsync(well.Id, request);
|
|
|
|
//assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
Assert.NotNull(response.Content);
|
|
Assert.True(response.Content.Any());
|
|
}
|
|
|
|
private static IEnumerable<WitsItemFloat> CreateWitsItems(int idTelemetry) =>
|
|
new[]
|
|
{
|
|
new WitsItemFloat
|
|
{
|
|
IdRecord = 1,
|
|
IdItem = 14,
|
|
Value = 4,
|
|
IdTelemetry = idTelemetry,
|
|
DateTime = DateTimeOffset.UtcNow
|
|
},
|
|
new WitsItemFloat
|
|
{
|
|
IdRecord = 1,
|
|
IdItem = 14,
|
|
Value = 5,
|
|
IdTelemetry = idTelemetry,
|
|
DateTime = DateTimeOffset.UtcNow
|
|
},
|
|
new WitsItemFloat
|
|
{
|
|
IdRecord = 1,
|
|
IdItem = 12,
|
|
Value = 5,
|
|
IdTelemetry = idTelemetry,
|
|
DateTime = DateTimeOffset.UtcNow.AddSeconds(10)
|
|
}
|
|
};
|
|
} |