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

40 lines
1.2 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;
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;
private readonly EventService service;
2022-02-07 15:10:18 +05:00
public EventServiceTest()
{
2022-11-15 17:44:48 +05:00
context = TestHelpter.MakeRealTestContext();
var telemetryTracker = new Mock<ITelemetryTracker>();
var imezoneServiceMock = new Mock<ITimezoneService>();
2023-02-22 12:37:43 +05:00
var telemetryService = new TelemetryService(context, TestHelpter.MemoryCache, telemetryTracker.Object, imezoneServiceMock.Object);
service = new EventService(context, TestHelpter.MemoryCache, 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());
}
}