DD.WellWorkover.Cloud/AsbCloudWebApi.Tests/ServicesTests/EventServiceTest.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2022-06-15 14:57:37 +05:00
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Services;
2022-02-07 15:10:18 +05:00
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
2022-06-15 14:57:37 +05:00
using AsbCloudInfrastructure.Services.SAUB;
using Moq;
2022-02-07 15:10:18 +05:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace AsbCloudWebApi.Tests.ServicesTests;
public class EventServiceTest
{
private readonly AsbCloudDbContext context;
2022-06-15 14:57:37 +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();
var telemetryTracker = new Mock<ITelemetryTracker>();
var imezoneServiceMock = new Mock<ITimezoneService>();
var telemetryService = new TelemetryService(context, telemetryTracker.Object, imezoneServiceMock.Object, cacheDb);
service = new EventService(context, telemetryService);
2022-02-07 15:10:18 +05:00
}
[Fact]
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);
2022-06-15 14:57:37 +05:00
2022-02-07 15:10:18 +05:00
Assert.Equal(2, context.TelemetryEvents.Count());
}
}