From 4fa00de88ee1c217a2461dbee6e813aad8e3755d Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Mon, 25 Nov 2024 10:30:37 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D1=81=D1=82=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF=D0=BE=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0=D0=BC=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B2=D1=8C=D1=8E=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SetpointControllerTest.cs | 6 +++--- Persistence.Repository/Repositories/SetpointRepository.cs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) 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());