Files
lmxopcua/tests/ZB.MOM.WW.LmxOpcUa.Tests/Redundancy/ServiceLevelCalculatorTests.cs
Joseph Doherty 41a6b66943 Apply code style formatting and restore partial modifiers on Avalonia views
Linter/formatter pass across the full codebase. Restores required partial
keyword on AXAML code-behind classes that the formatter incorrectly removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 07:58:13 -04:00

59 lines
1.5 KiB
C#

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);
}
}
}