using System.Net; using AsbCloudDb.Model; using AsbCloudWebApi.IntegrationTests.Clients; using Microsoft.EntityFrameworkCore; using Xunit; namespace AsbCloudWebApi.IntegrationTests.Controllers; public class SetpointsControllerTest : BaseIntegrationTest { private readonly ISetpointsClient client; public SetpointsControllerTest(WebAppFactoryFixture factory) : base(factory) { client = factory.GetAuthorizedHttpClient(string.Empty); } [Fact] public async Task GetByTelemetryUidAsync_returns_success() { //arrange var well = await dbContext.Wells .Include(w => w.Telemetry) .FirstAsync(); var entity = new SetpointsRequest { IdWell = well.Id, UploadDate = DateTimeOffset.UtcNow, ObsolescenceSec = 15, IdState = 1, IdAuthor = 1 }; var entry = dbContext.SetpointsRequests.Add(entity); await dbContext.SaveChangesAsync(); entry.State = EntityState.Detached; //act var response = await client.GetByTelemetryUidAsync(well.Telemetry!.RemoteUid); //assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Content); Assert.Single(response.Content); var setpoints = await dbContext.SetpointsRequests.ToArrayAsync(); foreach (var setpoint in setpoints) Assert.Equal(2, setpoint.IdState); } }