using System; using System.Collections.Generic; using Centron.BusinessLogic; using Centron.BusinessLogic.Telemetry; using Centron.Data.Entities.Telemetry; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Telemetry { public class TelemetryUpsertApiCall_InsertNew : EndToEndTest { public TelemetryUpsertApiCall_InsertNew(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { int methodI3D = 0; this.WithSession(session => { var resolve = session.GetBL().ResolveApiMethodNameI3Ds(new[] { "GetSomething" }); Assert.True(resolve.IsSuccess); methodI3D = resolve.Data["GetSomething"]; }); var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc); var increments = new List { new() { UserID = 11, UserKind = TelemetryUserKind.User, LicenseKind = TelemetryLicenseKind.Centron, MethodNameI3D = methodI3D, BucketStartUtc = bucket, Increment = 4 } }; this.WithSession(session => { var result = session.GetBL().UpsertApiCallBatch(increments); Assert.True(result.IsSuccess); }); var count = this.Sql( $"SELECT [Count] FROM dbo.ApiCallTelemetry WHERE UserID = 11 AND UserKind = 0 AND LicenseKind = {(short)TelemetryLicenseKind.Centron} AND MethodNameI3D = {methodI3D} AND BucketStartUtc = '2026-05-02T12:15:00'"); Assert.Equal(4, count); } } }