DD.WellWorkover.Cloud/AsbCloudWebApi.Tests/ServicesTests/EventServiceTest.cs
2022-11-18 16:20:12 +05:00

40 lines
1.2 KiB
C#

using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.SAUB;
using Moq;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace AsbCloudWebApi.Tests.ServicesTests;
public class EventServiceTest
{
private readonly AsbCloudDbContext context;
private readonly EventService service;
public EventServiceTest()
{
context = TestHelpter.MakeRealTestContext();
var telemetryTracker = new Mock<ITelemetryTracker>();
var imezoneServiceMock = new Mock<ITimezoneService>();
var telemetryService = new TelemetryService(context, telemetryTracker.Object, imezoneServiceMock.Object);
service = new EventService(context, telemetryService);
}
[Fact]
public async Task Upsert_telemetry_events()
{
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());
}
}