forked from ddrilling/AsbCloudServer
fix all integration test
This commit is contained in:
parent
7eedf62419
commit
4a1809345f
@ -125,8 +125,8 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : IProcessMapPlanBaseRe
|
|||||||
{
|
{
|
||||||
var moment = request.Moment.Value.ToUniversalTime();
|
var moment = request.Moment.Value.ToUniversalTime();
|
||||||
query = query
|
query = query
|
||||||
.Where(e => e.Creation < moment)
|
.Where(e => e.Creation <= moment)
|
||||||
.Where(e => e.Obsolete == null || e.Obsolete > moment);
|
.Where(e => e.Obsolete == null || e.Obsolete >= moment);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = await query.ToArrayAsync(token);
|
var entities = await query.ToArrayAsync(token);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudDb.Model.ProcessMaps;
|
||||||
using AsbCloudWebApi.IntegrationTests.Clients;
|
using AsbCloudWebApi.IntegrationTests.Clients;
|
||||||
using AsbCloudWebApi.IntegrationTests.TestFakers;
|
using AsbCloudWebApi.IntegrationTests.TestFakers;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@ -22,6 +24,10 @@ public class AdminDepositControllerTests : BaseIntegrationTest
|
|||||||
public async Task InsertAsync_ReturnsSuccess_WhenNewItemIsValid()
|
public async Task InsertAsync_ReturnsSuccess_WhenNewItemIsValid()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
|
var dbset = dbContext.Set<Deposit>();
|
||||||
|
dbset.RemoveRange(dbset);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
var expectedDto = EntitiesFaker.Deposit.Generate().Adapt<DepositBaseDto>();
|
var expectedDto = EntitiesFaker.Deposit.Generate().Adapt<DepositBaseDto>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
@ -42,6 +48,10 @@ public class AdminDepositControllerTests : BaseIntegrationTest
|
|||||||
public async Task InsertRangeAsync_ReturnsSuccess_WhenAllNewItemsIsValid()
|
public async Task InsertRangeAsync_ReturnsSuccess_WhenAllNewItemsIsValid()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
|
var dbset = dbContext.Set<Deposit>();
|
||||||
|
dbset.RemoveRange(dbset);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
var dto = EntitiesFaker.Deposit.Generate().Adapt<DepositBaseDto>();
|
var dto = EntitiesFaker.Deposit.Generate().Adapt<DepositBaseDto>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
|
@ -85,6 +85,8 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
||||||
|
dbset.RemoveRange(dbset);
|
||||||
|
dbContext.SaveChanges();
|
||||||
var expected = dto.Adapt<ProcessMapPlanDrillingDto>();
|
var expected = dto.Adapt<ProcessMapPlanDrillingDto>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
@ -363,17 +365,18 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
||||||
dbset.RemoveRange(dbset);
|
dbset.RemoveRange(dbset);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
var now = DateTimeOffset.UtcNow;
|
||||||
var entityDeleted = entity.Adapt<ProcessMapPlanDrilling>();
|
var entityDeleted = entity.Adapt<ProcessMapPlanDrilling>();
|
||||||
entityDeleted.Creation = entity.Creation.AddDays(-1);
|
entityDeleted.Creation = now;
|
||||||
entityDeleted.Obsolete = entity.Creation;
|
entityDeleted.Obsolete = now.AddMinutes(1);
|
||||||
entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted;
|
entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted;
|
||||||
entityDeleted.IdEditor = 1;
|
entityDeleted.IdEditor = 1;
|
||||||
entityDeleted.Comment = "nothing";
|
entityDeleted.Comment = "nothing";
|
||||||
dbset.Add(entityDeleted);
|
dbset.Add(entityDeleted);
|
||||||
|
|
||||||
var entityDeleted2 = entity.Adapt<ProcessMapPlanDrilling>();
|
var entityDeleted2 = entity.Adapt<ProcessMapPlanDrilling>();
|
||||||
entityDeleted2.Obsolete = entity.Creation.AddSeconds(1);
|
entityDeleted2.Creation = now.AddMinutes(1);
|
||||||
|
entityDeleted2.Obsolete = now.AddMinutes(2);
|
||||||
entityDeleted2.IdState = ProcessMapPlanBase.IdStateDeleted;
|
entityDeleted2.IdState = ProcessMapPlanBase.IdStateDeleted;
|
||||||
entityDeleted2.IdEditor = 1;
|
entityDeleted2.IdEditor = 1;
|
||||||
entityDeleted2.Comment = "nothing";
|
entityDeleted2.Comment = "nothing";
|
||||||
@ -388,14 +391,14 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
var request = new ProcessMapPlanBaseRequest
|
var request = new ProcessMapPlanBaseRequest
|
||||||
{
|
{
|
||||||
IdWell = dto.IdWell,
|
IdWell = dto.IdWell,
|
||||||
Moment = entityDeleted.Creation
|
Moment = now.AddMinutes(0.5),
|
||||||
};
|
};
|
||||||
var response = await client.Get(dto.IdWell, request);
|
var response = await client.Get(dto.IdWell, request);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.Equal(2, response.Content.Count());
|
Assert.Equal(1, response.Content.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
Loading…
Reference in New Issue
Block a user