using Admin.NET.Plugin.AiDOP.DataPlatform.Core.Connectors; using Xunit; namespace Admin.NET.Plugin.AiDOP.Tests.DataPlatform; public sealed class MdpRelationalCapacityTests { [Fact] public void ExtrapolatesObservedBatchRangeAndKeepsRawBytesPerRow() { var estimate = RelationalCapacityEstimate.FromSamples(100, [ new(10, 500, 100, 50, 100, 200, 50), new(20, 1500, 400, 100, 100, 700, 100) ]); Assert.Equal(30, estimate.SampleRows); Assert.Equal(66.67m, estimate.RawBytesPerRow); Assert.Equal(6667, estimate.FullRawBytes); Assert.Equal(5m, estimate.FullSecondsLow); Assert.Equal(7m, estimate.FullSecondsHigh); } [Fact] public void PreservesUnknownScaleAndSingleBatchEvidence() { Assert.Null(RelationalCapacityEstimate.FromSamples(100, []).RawBytesPerRow); var estimate = RelationalCapacityEstimate.FromSamples(null, [new(2, 100, 10, 20, 10, 50, 10)]); Assert.Equal(1, estimate.SampleBatches); Assert.Equal(50m, estimate.RawBytesPerRow); Assert.Null(estimate.FullSecondsLow); Assert.Null(estimate.FullRawBytes); } [Fact] public void DistinguishesAnEmptySourceFromMissingSourceStatistics() { var estimate = RelationalCapacityEstimate.FromSamples(0, []); Assert.Equal(0, estimate.FullRawBytes); Assert.Null(estimate.FullSecondsLow); } [Fact] public void ObservedRowsTakePrecedenceWhenCatalogStatisticsLag() { RelationalCapacityBatch[] batches = [new(4, 1060, 20, 250, 10, 800, 250)]; var allRows = RelationalCapacityEstimate.FromSamples(3, batches, reachedEnd: true); Assert.Equal(4, allRows.SourceRows); Assert.Equal("sample", allRows.SourceRowsBasis); Assert.Equal(1060, allRows.FullRawBytes); var incomplete = RelationalCapacityEstimate.FromSamples(3, batches); Assert.Equal(4, incomplete.SourceRows); Assert.Equal("sample-floor", incomplete.SourceRowsBasis); } }