using Xunit; using ZB.MOM.WW.OtOpcUa.Core.Abstractions; // HistoryAggregateType using ZB.MOM.WW.HistorianGateway.Contracts.Grpc; // RetrievalMode using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Mapping; namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests.Mapping; public sealed class AggregateModeMapperTests { [Theory] [InlineData(HistoryAggregateType.Average, RetrievalMode.TimeWeightedAverage)] [InlineData(HistoryAggregateType.Minimum, RetrievalMode.MinimumWithTime)] [InlineData(HistoryAggregateType.Maximum, RetrievalMode.MaximumWithTime)] [InlineData(HistoryAggregateType.Total, RetrievalMode.Integral)] [InlineData(HistoryAggregateType.Count, RetrievalMode.Counter)] public void Maps_each_aggregate(HistoryAggregateType a, RetrievalMode expected) => Assert.Equal(expected, AggregateModeMapper.ToRetrievalMode(a)); [Fact] // matrix guard: every member is either mapped or explicitly reported as not supported public void Every_aggregate_member_is_mapped_or_reports_not_supported() { var original = new[] { HistoryAggregateType.Average, HistoryAggregateType.Minimum, HistoryAggregateType.Maximum, HistoryAggregateType.Total, HistoryAggregateType.Count, }; foreach (var a in Enum.GetValues()) { if (original.Contains(a)) _ = AggregateModeMapper.ToRetrievalMode(a); else Assert.Throws(() => AggregateModeMapper.ToRetrievalMode(a)); } } [Fact] public void Undefined_value_is_a_programming_error_not_a_not_supported() => Assert.Throws(() => AggregateModeMapper.ToRetrievalMode((HistoryAggregateType)9999)); }