using System.Net; using Persistence.IntegrationTests.Clients; using Xunit; namespace Persistence.IntegrationTests.Controllers { public class SetpointControllerTest : BaseIntegrationTest { private ISetpointClient client; private class TestObject { public string? value1 { get; set; } public int value2 { get; set; } public double value3 { get; set; } } public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory) { client = factory.GetHttpClient(string.Empty); } [Fact] public async Task GetHistoryAsync_returns_success() { //arrange var setpointKeys = new List() { Guid.NewGuid(), Guid.NewGuid() }; var historyMoment = DateTimeOffset.Now.ToUniversalTime(); //act var response = await client.GetHistoryAsync(setpointKeys, historyMoment); //assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); } [Fact] public async Task GetLogAsync_returns_success() { //arrange var setpointKeys = new List() { Guid.NewGuid(), Guid.NewGuid() }; //act var response = await client.GetLogAsync(setpointKeys); //assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); } [Fact] public async Task SaveAsync_returns_success() { //arrange var setpointKey = Guid.NewGuid(); var setpointValue = new TestObject() { value1 = "1", value2 = 2, value3 = 3.3 }; //act var response = await client.SaveAsync(setpointKey, setpointValue); //assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(1, response.Content); } } }