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 Microsoft.Extensions.DependencyInjection;
|
||||||
using Xunit;
|
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 TimeSpan timeSpan = TimeSpan.FromHours(1);
|
||||||
|
|
||||||
private static readonly DataSaubStatDto[] statDtos = new DataSaubStatDto[2]
|
private static readonly DataSaubStatDto[] statDtos = new DataSaubStatDto[2]
|
||||||
{
|
{
|
||||||
new DataSaubStatDto()
|
new()
|
||||||
{
|
{
|
||||||
IdTelemetry = 1,
|
IdTelemetry = 1,
|
||||||
DateEnd = new DateTimeOffset(2024, 1, 1, 20, 25, 0, timeSpan),
|
DateEnd = new DateTimeOffset(2024, 1, 1, 20, 25, 0, timeSpan),
|
||||||
@ -39,7 +39,7 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
|||||||
RotorTorqueLimitMax = 9.0,
|
RotorTorqueLimitMax = 9.0,
|
||||||
Speed = 10.0
|
Speed = 10.0
|
||||||
},
|
},
|
||||||
new DataSaubStatDto()
|
new()
|
||||||
{
|
{
|
||||||
IdTelemetry = 1,
|
IdTelemetry = 1,
|
||||||
DateEnd = new DateTimeOffset(2024, 2, 2, 20, 25, 0, timeSpan),
|
DateEnd = new DateTimeOffset(2024, 2, 2, 20, 25, 0, timeSpan),
|
||||||
@ -85,6 +85,7 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
|||||||
{
|
{
|
||||||
//prepare
|
//prepare
|
||||||
dbContext.CleanupDbSet<DataSaubStat>();
|
dbContext.CleanupDbSet<DataSaubStat>();
|
||||||
|
dbContext.CleanupDbSet<WellOperationCategory>();
|
||||||
|
|
||||||
var dbSetSaubStat = dbContext.Set<DataSaubStat>();
|
var dbSetSaubStat = dbContext.Set<DataSaubStat>();
|
||||||
var dbSetCategories = dbContext.Set<WellOperationCategory>();
|
var dbSetCategories = dbContext.Set<WellOperationCategory>();
|
||||||
@ -92,6 +93,8 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
|||||||
var entities = statDtos.Select(stat => ConvertToEntity(stat));
|
var entities = statDtos.Select(stat => ConvertToEntity(stat));
|
||||||
|
|
||||||
dbSetCategories.Add(category);
|
dbSetCategories.Add(category);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
dbSetSaubStat.AddRange(entities);
|
dbSetSaubStat.AddRange(entities);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
@ -111,16 +114,14 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
|||||||
{
|
{
|
||||||
//prepare
|
//prepare
|
||||||
dbContext.CleanupDbSet<DataSaubStat>();
|
dbContext.CleanupDbSet<DataSaubStat>();
|
||||||
|
|
||||||
//act
|
|
||||||
var dbSet = dbContext.Set<DataSaubStat>();
|
var dbSet = dbContext.Set<DataSaubStat>();
|
||||||
dbSet.RemoveRange(dbSet);
|
|
||||||
|
|
||||||
var dbSetCategories = dbContext.Set<WellOperationCategory>();
|
var dbSetCategories = dbContext.Set<WellOperationCategory>();
|
||||||
dbSetCategories.Add(category);
|
dbSetCategories.Add(category);
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
//act
|
||||||
var result = await dataSaubStatRepository.InsertRangeAsync(statDtos, CancellationToken.None);
|
var result = await dataSaubStatRepository.InsertRangeAsync(statDtos, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
@ -162,4 +163,3 @@ namespace AsbCloudWebApi.IntegrationTests.Repository
|
|||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user