using ZB.MOM.WW.MxGateway.Contracts.Proto; using ZB.MOM.WW.MxGateway.Server.Metrics; namespace ZB.MOM.WW.MxGateway.Tests.Metrics; public sealed class MxEventFamilyNamesTests { /// /// Every defined family maps to exactly the name produces, so /// switching the per-event metric tags to the cached lookup changes no exported tag value. /// [Fact] public void Get_ForEveryDefinedFamily_MatchesEnumToString() { foreach (MxEventFamily family in Enum.GetValues()) { Assert.Equal(family.ToString(), MxEventFamilyNames.Get(family)); } } /// A defined family returns the same cached string instance on every call (no per-event allocation). [Fact] public void Get_ForDefinedFamily_ReturnsCachedInstance() { Assert.Same( MxEventFamilyNames.Get(MxEventFamily.OnDataChange), MxEventFamilyNames.Get(MxEventFamily.OnDataChange)); } /// /// A numeric value the contract does not define (a newer worker, or a malformed frame) still /// produces the form rather than throwing. /// [Fact] public void Get_ForUndefinedValue_FallsBackToToString() { MxEventFamily undefined = (MxEventFamily)987654; Assert.Equal(undefined.ToString(), MxEventFamilyNames.Get(undefined)); } }