DD.WellWorkover.Cloud/AsbCloudWebApi.IntegrationTests/Controllers/GtrControllerTests.cs

68 lines
1.5 KiB
C#
Raw Normal View History

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();
2024-04-08 16:32:00 +05:00
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)
}
};
}