forked from ddrilling/AsbCloudServer
remove CacheDB from tests
This commit is contained in:
parent
342f5845f4
commit
431d291782
@ -22,7 +22,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
protected override ICrudService<DepositDto> MakeService()
|
protected override ICrudService<DepositDto> MakeService()
|
||||||
{
|
{
|
||||||
var dbContext = TestHelpter.MakeRealTestContext();
|
var dbContext = TestHelpter.MakeRealTestContext();
|
||||||
return new CrudCacheServiceBase<DepositDto, Deposit>(dbContext);
|
return new CrudCacheServiceBase<DepositDto, Deposit>(dbContext, TestHelpter.MemoryCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ using AsbCloudApp.Requests;
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Repository;
|
using AsbCloudInfrastructure.Repository;
|
||||||
using AsbCloudInfrastructure.Services;
|
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System;
|
using System;
|
||||||
@ -19,7 +17,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
public class DetectedOperationServiceTest
|
public class DetectedOperationServiceTest
|
||||||
{
|
{
|
||||||
private readonly AsbCloudDbContext context;
|
private readonly AsbCloudDbContext context;
|
||||||
private readonly CacheDb cacheDb;
|
|
||||||
private readonly DetectedOperationService service;
|
private readonly DetectedOperationService service;
|
||||||
private readonly DetectedOperationRequest request;
|
private readonly DetectedOperationRequest request;
|
||||||
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
|
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Repositories;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using AsbCloudInfrastructure.Repository;
|
|
||||||
using AsbCloudInfrastructure.Services;
|
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
using AsbCloudInfrastructure.Services.SAUB;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -14,13 +13,11 @@ namespace AsbCloudWebApi.Tests.ServicesTests;
|
|||||||
public class EventServiceTest
|
public class EventServiceTest
|
||||||
{
|
{
|
||||||
private readonly AsbCloudDbContext context;
|
private readonly AsbCloudDbContext context;
|
||||||
private readonly CacheDb cacheDb;
|
|
||||||
private readonly EventService service;
|
private readonly EventService service;
|
||||||
|
|
||||||
public EventServiceTest()
|
public EventServiceTest()
|
||||||
{
|
{
|
||||||
context = TestHelpter.MakeRealTestContext();
|
context = TestHelpter.MakeRealTestContext();
|
||||||
cacheDb = new CacheDb();
|
|
||||||
var telemetryTracker = new Mock<ITelemetryTracker>();
|
var telemetryTracker = new Mock<ITelemetryTracker>();
|
||||||
var imezoneServiceMock = new Mock<ITimezoneService>();
|
var imezoneServiceMock = new Mock<ITimezoneService>();
|
||||||
var telemetryService = new TelemetryService(context, telemetryTracker.Object, imezoneServiceMock.Object);
|
var telemetryService = new TelemetryService(context, telemetryTracker.Object, imezoneServiceMock.Object);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using AsbCloudInfrastructure.Services;
|
using AsbCloudInfrastructure.Services;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -19,7 +17,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
|
|
||||||
context = TestHelpter.MakeRealTestContext();
|
context = TestHelpter.MakeRealTestContext();
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
service = new FileCategoryService(context);
|
service = new FileCategoryService(context, TestHelpter.MemoryCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileCategoryServiceTest()
|
~FileCategoryServiceTest()
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
using AsbCloudInfrastructure.Services.SAUB;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System;
|
using System;
|
||||||
@ -20,9 +19,9 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
private readonly Mock<ITimezoneService> timezoneService;
|
private readonly Mock<ITimezoneService> timezoneService;
|
||||||
private readonly SimpleTimezoneDto timezone;
|
private readonly SimpleTimezoneDto timezone;
|
||||||
private readonly AsbCloudDbContext context;
|
private readonly AsbCloudDbContext context;
|
||||||
private readonly CacheDb cacheDb;
|
|
||||||
private readonly TelemetryService telemetryService;
|
private readonly TelemetryService telemetryService;
|
||||||
|
private readonly TelemetryUserService telemetryUserService;
|
||||||
|
private readonly TelemetryDataCache<TelemetryDataSaubDto> telemetryDataSaubCache;
|
||||||
private readonly DateTime drillingStartDate;
|
private readonly DateTime drillingStartDate;
|
||||||
private readonly string uuid;
|
private readonly string uuid;
|
||||||
public TelemetryDataSaubServiceTest()
|
public TelemetryDataSaubServiceTest()
|
||||||
@ -41,9 +40,9 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
.Returns(timezone);
|
.Returns(timezone);
|
||||||
|
|
||||||
context = TestHelpter.MakeRealTestContext();
|
context = TestHelpter.MakeRealTestContext();
|
||||||
cacheDb = new CacheDb();
|
|
||||||
telemetryService = new TelemetryService(context, telemetryTracker.Object, timezoneService.Object);
|
telemetryService = new TelemetryService(context, telemetryTracker.Object, timezoneService.Object);
|
||||||
|
telemetryUserService = new TelemetryUserService(context, telemetryService, TestHelpter.MemoryCache);
|
||||||
|
telemetryDataSaubCache = TelemetryDataCache<TelemetryDataSaubDto>.GetInstance<TelemetryDataSaub>(context, out Task _);
|
||||||
var info = new TelemetryInfoDto
|
var info = new TelemetryInfoDto
|
||||||
{
|
{
|
||||||
TimeZoneOffsetTotalHours = timezone.Hours,
|
TimeZoneOffsetTotalHours = timezone.Hours,
|
||||||
@ -64,7 +63,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
public async Task UpdateDataAsync()
|
public async Task UpdateDataAsync()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var telemetryDataSaubService = new TelemetryDataSaubService(context, telemetryService, null, cacheDb);
|
var telemetryDataSaubService = new TelemetryDataSaubService(context, telemetryService, telemetryUserService, telemetryDataSaubCache);
|
||||||
|
|
||||||
var now = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(timezone.Hours)).DateTime;
|
var now = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(timezone.Hours)).DateTime;
|
||||||
var tuser = "Завулон";
|
var tuser = "Завулон";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -10,16 +11,14 @@ namespace AsbCloudWebApi.Tests
|
|||||||
{
|
{
|
||||||
// Попробовать когда-нибудь https://github.com/MichalJankowskii/Moq.EntityFrameworkCore
|
// Попробовать когда-нибудь https://github.com/MichalJankowskii/Moq.EntityFrameworkCore
|
||||||
|
|
||||||
|
public static IMemoryCache MemoryCache = new MemoryCache(new MemoryCacheOptions());
|
||||||
|
|
||||||
public static AsbCloudDbContext MakeRealTestContext()
|
public static AsbCloudDbContext MakeRealTestContext()
|
||||||
{
|
{
|
||||||
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
||||||
//.UseInMemoryDatabase(System.Guid.NewGuid().ToString())
|
|
||||||
//.ConfigureWarnings(configBuilder =>
|
|
||||||
// configBuilder.Ignore(InMemoryEventId.TransactionIgnoredWarning))
|
|
||||||
.UseNpgsql("Host=localhost;Database=tests;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True")
|
.UseNpgsql("Host=localhost;Database=tests;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True")
|
||||||
.Options;
|
.Options;
|
||||||
var context = new AsbCloudDbContext(options);
|
var context = new AsbCloudDbContext(options);
|
||||||
//context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
context.Database.EnsureCreated();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user