forked from ddrilling/AsbCloudServer
fix tests
This commit is contained in:
parent
2b4000ce6b
commit
1e27b7e559
@ -5,15 +5,15 @@ using Mapster;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Xunit;
|
||||
|
||||
namespace AsbCloudWebApi.IntegrationTests.Repository
|
||||
namespace AsbCloudWebApi.IntegrationTests.Repository;
|
||||
|
||||
public class DataSaubStatRepositoryTest : BaseIntegrationTest
|
||||
{
|
||||
public class DataSaubStatRepositoryTest : BaseIntegrationTest
|
||||
{
|
||||
private static readonly TimeSpan timeSpan = TimeSpan.FromHours(1);
|
||||
|
||||
private static readonly DataSaubStatDto[] statDtos = new DataSaubStatDto[2]
|
||||
{
|
||||
new DataSaubStatDto()
|
||||
new()
|
||||
{
|
||||
IdTelemetry = 1,
|
||||
DateEnd = new DateTimeOffset(2024, 1, 1, 20, 25, 0, timeSpan),
|
||||
@ -39,7 +39,7 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
||||
RotorTorqueLimitMax = 9.0,
|
||||
Speed = 10.0
|
||||
},
|
||||
new DataSaubStatDto()
|
||||
new()
|
||||
{
|
||||
IdTelemetry = 1,
|
||||
DateEnd = new DateTimeOffset(2024, 2, 2, 20, 25, 0, timeSpan),
|
||||
@ -85,6 +85,7 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
||||
{
|
||||
//prepare
|
||||
dbContext.CleanupDbSet<DataSaubStat>();
|
||||
dbContext.CleanupDbSet<WellOperationCategory>();
|
||||
|
||||
var dbSetSaubStat = dbContext.Set<DataSaubStat>();
|
||||
var dbSetCategories = dbContext.Set<WellOperationCategory>();
|
||||
@ -92,6 +93,8 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
||||
var entities = statDtos.Select(stat => ConvertToEntity(stat));
|
||||
|
||||
dbSetCategories.Add(category);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
dbSetSaubStat.AddRange(entities);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
@ -111,16 +114,14 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
||||
{
|
||||
//prepare
|
||||
dbContext.CleanupDbSet<DataSaubStat>();
|
||||
|
||||
//act
|
||||
var dbSet = dbContext.Set<DataSaubStat>();
|
||||
dbSet.RemoveRange(dbSet);
|
||||
|
||||
var dbSetCategories = dbContext.Set<WellOperationCategory>();
|
||||
dbSetCategories.Add(category);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
//act
|
||||
var result = await dataSaubStatRepository.InsertRangeAsync(statDtos, CancellationToken.None);
|
||||
|
||||
//assert
|
||||
@ -161,5 +162,4 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user