diff --git a/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs b/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs index 2fcfc52..a33c15d 100644 --- a/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs +++ b/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs @@ -49,7 +49,7 @@ namespace Persistence.IntegrationTests.Controllers Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Content); Assert.NotEmpty(response.Content); - Assert.Equal(response.Content.FirstOrDefault()?.Key, setpointKey); + Assert.Equal(setpointKey, response.Content.FirstOrDefault()?.Key); } [Fact] @@ -87,7 +87,7 @@ namespace Persistence.IntegrationTests.Controllers Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Content); Assert.NotEmpty(response.Content); - Assert.Equal(response.Content.FirstOrDefault()?.Key, setpointKey); + Assert.Equal(setpointKey, response.Content.FirstOrDefault()?.Key); } [Fact] @@ -122,7 +122,7 @@ namespace Persistence.IntegrationTests.Controllers Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Content); Assert.NotEmpty(response.Content); - Assert.Equal(response.Content.FirstOrDefault().Value.FirstOrDefault()?.Key, setpointKey); + Assert.Equal(setpointKey, response.Content.FirstOrDefault()?.Key); } [Fact] diff --git a/Persistence.Repository/Repositories/SetpointRepository.cs b/Persistence.Repository/Repositories/SetpointRepository.cs index 2c08e71..7f81c29 100644 --- a/Persistence.Repository/Repositories/SetpointRepository.cs +++ b/Persistence.Repository/Repositories/SetpointRepository.cs @@ -35,6 +35,7 @@ namespace Persistence.Repository.Repositories .ToArrayAsync(token); var filteredEntities = entities .GroupBy(e => e.Key) + .Select(e => e.OrderBy(o => o.Created)) .Select(e => e.Where(e => e.Created <= historyMoment).Last()); var dtos = filteredEntities .Select(e => e.Adapt());