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();
|
||||
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);
|
||||
|
@ -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<DepositBaseDto>();
|
||||
//arrange
|
||||
var dbset = dbContext.Set<Deposit>();
|
||||
dbset.RemoveRange(dbset);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
var expectedDto = EntitiesFaker.Deposit.Generate().Adapt<DepositBaseDto>();
|
||||
|
||||
//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<DepositBaseDto>();
|
||||
//arrange
|
||||
var dbset = dbContext.Set<Deposit>();
|
||||
dbset.RemoveRange(dbset);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
//act
|
||||
var responce = await client.InsertRangeAsync(new[] { dto });
|
||||
var dto = EntitiesFaker.Deposit.Generate().Adapt<DepositBaseDto>();
|
||||
|
||||
//act
|
||||
var responce = await client.InsertRangeAsync(new[] { dto });
|
||||
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, responce.StatusCode);
|
||||
|
@ -85,6 +85,8 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
||||
{
|
||||
//arrange
|
||||
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
||||
dbset.RemoveRange(dbset);
|
||||
dbContext.SaveChanges();
|
||||
var expected = dto.Adapt<ProcessMapPlanDrillingDto>();
|
||||
|
||||
//act
|
||||
@ -363,17 +365,18 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
||||
var dbset = dbContext.Set<ProcessMapPlanDrilling>();
|
||||
dbset.RemoveRange(dbset);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var entityDeleted = entity.Adapt<ProcessMapPlanDrilling>();
|
||||
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<ProcessMapPlanDrilling>();
|
||||
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]
|
||||
|
Loading…
Reference in New Issue
Block a user