using Shouldly; using Xunit; using ZB.MOM.WW.LmxOpcUa.Host.OpcUa; namespace ZB.MOM.WW.LmxOpcUa.Tests.Redundancy { public class ServiceLevelCalculatorTests { private readonly ServiceLevelCalculator _calculator = new(); [Fact] public void FullyHealthy_Primary_ReturnsBase() { _calculator.Calculate(200, true, true).ShouldBe((byte)200); } [Fact] public void FullyHealthy_Secondary_ReturnsBaseMinusFifty() { _calculator.Calculate(150, true, true).ShouldBe((byte)150); } [Fact] public void MxAccessDown_ReducesServiceLevel() { _calculator.Calculate(200, false, true).ShouldBe((byte)100); } [Fact] public void DbDown_ReducesServiceLevel() { _calculator.Calculate(200, true, false).ShouldBe((byte)150); } [Fact] public void BothDown_ReturnsZero() { _calculator.Calculate(200, false, false).ShouldBe((byte)0); } [Fact] public void ClampedTo255() { _calculator.Calculate(255, true, true).ShouldBe((byte)255); } [Fact] public void ClampedToZero() { _calculator.Calculate(50, false, true).ShouldBe((byte)0); } [Fact] public void ZeroBase_BothHealthy_ReturnsZero() { _calculator.Calculate(0, true, true).ShouldBe((byte)0); } } }