diff --git a/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs index e6dcda12..963dcaf1 100644 --- a/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs +++ b/AsbCloudInfrastructure/Repository/ProcessMapPlanBaseRepository.cs @@ -125,8 +125,8 @@ public class ProcessMapPlanBaseRepository : IProcessMapPlanBaseRe { var moment = request.Moment.Value.ToUniversalTime(); query = query - .Where(e => e.Creation < moment) - .Where(e => e.Obsolete == null || e.Obsolete > moment); + .Where(e => e.Creation <= moment) + .Where(e => e.Obsolete == null || e.Obsolete >= moment); } var entities = await query.ToArrayAsync(token); diff --git a/AsbCloudWebApi.IntegrationTests/Controllers/AdminDepositControllerTests.cs b/AsbCloudWebApi.IntegrationTests/Controllers/AdminDepositControllerTests.cs index f05c71ab..8fd089bf 100644 --- a/AsbCloudWebApi.IntegrationTests/Controllers/AdminDepositControllerTests.cs +++ b/AsbCloudWebApi.IntegrationTests/Controllers/AdminDepositControllerTests.cs @@ -1,5 +1,7 @@ using System.Net; using AsbCloudApp.Data; +using AsbCloudDb.Model; +using AsbCloudDb.Model.ProcessMaps; using AsbCloudWebApi.IntegrationTests.Clients; using AsbCloudWebApi.IntegrationTests.TestFakers; using Mapster; @@ -21,8 +23,12 @@ public class AdminDepositControllerTests : BaseIntegrationTest [Fact] public async Task InsertAsync_ReturnsSuccess_WhenNewItemIsValid() { - //arrange - var expectedDto = EntitiesFaker.Deposit.Generate().Adapt(); + //arrange + var dbset = dbContext.Set(); + dbset.RemoveRange(dbset); + dbContext.SaveChanges(); + + var expectedDto = EntitiesFaker.Deposit.Generate().Adapt(); //act var response = await client.InsertAsync(expectedDto); @@ -41,11 +47,15 @@ public class AdminDepositControllerTests : BaseIntegrationTest [Fact] public async Task InsertRangeAsync_ReturnsSuccess_WhenAllNewItemsIsValid() { - //arrange - var dto = EntitiesFaker.Deposit.Generate().Adapt(); + //arrange + var dbset = dbContext.Set(); + dbset.RemoveRange(dbset); + dbContext.SaveChanges(); - //act - var responce = await client.InsertRangeAsync(new[] { dto }); + var dto = EntitiesFaker.Deposit.Generate().Adapt(); + + //act + var responce = await client.InsertRangeAsync(new[] { dto }); //assert Assert.Equal(HttpStatusCode.OK, responce.StatusCode); diff --git a/AsbCloudWebApi.IntegrationTests/Controllers/ProcessMapPlanDrillingControllerTest.cs b/AsbCloudWebApi.IntegrationTests/Controllers/ProcessMapPlanDrillingControllerTest.cs index d3916869..9a5f3844 100644 --- a/AsbCloudWebApi.IntegrationTests/Controllers/ProcessMapPlanDrillingControllerTest.cs +++ b/AsbCloudWebApi.IntegrationTests/Controllers/ProcessMapPlanDrillingControllerTest.cs @@ -85,6 +85,8 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest { //arrange var dbset = dbContext.Set(); + dbset.RemoveRange(dbset); + dbContext.SaveChanges(); var expected = dto.Adapt(); //act @@ -363,17 +365,18 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest var dbset = dbContext.Set(); dbset.RemoveRange(dbset); dbContext.SaveChanges(); - + var now = DateTimeOffset.UtcNow; var entityDeleted = entity.Adapt(); - entityDeleted.Creation = entity.Creation.AddDays(-1); - entityDeleted.Obsolete = entity.Creation; + entityDeleted.Creation = now; + entityDeleted.Obsolete = now.AddMinutes(1); entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted; entityDeleted.IdEditor = 1; entityDeleted.Comment = "nothing"; dbset.Add(entityDeleted); var entityDeleted2 = entity.Adapt(); - entityDeleted2.Obsolete = entity.Creation.AddSeconds(1); + entityDeleted2.Creation = now.AddMinutes(1); + entityDeleted2.Obsolete = now.AddMinutes(2); entityDeleted2.IdState = ProcessMapPlanBase.IdStateDeleted; entityDeleted2.IdEditor = 1; entityDeleted2.Comment = "nothing"; @@ -388,14 +391,14 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest var request = new ProcessMapPlanBaseRequest { IdWell = dto.IdWell, - Moment = entityDeleted.Creation + Moment = now.AddMinutes(0.5), }; var response = await client.Get(dto.IdWell, request); //assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Content); - Assert.Equal(2, response.Content.Count()); + Assert.Equal(1, response.Content.Count()); } [Fact]