2022-02-07 15:10:18 +05:00
|
|
|
using AsbCloudDb.Model;
|
|
|
|
using AsbCloudInfrastructure.Services.Cache;
|
|
|
|
using AsbCloudInfrastructure.Services;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
using Moq;
|
|
|
|
using Xunit;
|
2022-04-08 13:10:06 +05:00
|
|
|
using AsbCloudApp.Data.SAUB;
|
2022-05-22 21:18:43 +05:00
|
|
|
using AsbCloudInfrastructure.Services.SAUB;
|
2022-02-07 15:10:18 +05:00
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Tests.ServicesTests;
|
|
|
|
|
|
|
|
public class EventServiceTest
|
|
|
|
{
|
|
|
|
private readonly AsbCloudDbContext context;
|
2022-06-10 10:36:51 +05:00
|
|
|
private readonly CacheDb cacheDb;
|
|
|
|
private readonly EventService service;
|
2022-02-07 15:10:18 +05:00
|
|
|
|
|
|
|
public EventServiceTest()
|
|
|
|
{
|
|
|
|
context = TestHelpter.MakeTestContext();
|
|
|
|
cacheDb = new CacheDb();
|
2022-06-10 10:36:51 +05:00
|
|
|
var telemetryTracker = new Mock<ITelemetryTracker>();
|
|
|
|
var imezoneServiceMock = new Mock<ITimezoneService>();
|
|
|
|
var telemetryService = new TelemetryService(context, telemetryTracker.Object, imezoneServiceMock.Object, cacheDb);
|
2022-06-10 17:36:03 +05:00
|
|
|
service = new EventService(context, telemetryService);
|
2022-02-07 15:10:18 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2022-06-10 10:36:51 +05:00
|
|
|
public async Task Upsert_telemetry_events()
|
2022-02-07 15:10:18 +05:00
|
|
|
{
|
|
|
|
var dtos = new List<EventDto>
|
|
|
|
{
|
|
|
|
new EventDto {Id = 1, IdCategory = 1, Message = "Test message 1"},
|
|
|
|
new EventDto {Id = 2, IdCategory = 1, Message = "Test message 2"}
|
|
|
|
};
|
|
|
|
|
|
|
|
await service.UpsertAsync("uid", dtos);
|
|
|
|
|
|
|
|
Assert.Equal(2, context.TelemetryEvents.Count());
|
|
|
|
}
|
|
|
|
}
|