Files
MBN_STOCK_WEBVIEW/tests/MBN_STOCK_WEBVIEW.Playout.Tests/LiveAuthorizationTests.cs

41 lines
1.4 KiB
C#

using MBN_STOCK_WEBVIEW.Playout.Safety;
namespace MBN_STOCK_WEBVIEW.Playout.Tests;
public sealed class LiveAuthorizationTests
{
[Theory]
[InlineData(null, false)]
[InlineData("I_AUTHORIZE_LIVE_PROGRAM_OUTPUT_FOR_THIS_LAUNCH ", false)]
[InlineData("i_authorize_live_program_output_for_this_launch", false)]
[InlineData("wrong", false)]
[InlineData(
PlayoutOptionsLoader.RequiredLiveAuthorizationValue,
true)]
public void EnvironmentAuthorization_RequiresExactPerLaunchValue(
string? value,
bool expected)
{
using var environment = new EnvironmentScope()
.Set(PlayoutOptionsLoader.LiveAuthorizationEnvironmentVariable, value);
var authorization = new EnvironmentLiveAuthorization();
Assert.Equal(expected, authorization.IsAuthorizedForThisLaunch);
}
[Fact]
public void EnvironmentAuthorization_IsCapturedOnceAndCannotBeArmedAfterConstruction()
{
using var environment = new EnvironmentScope()
.Set(PlayoutOptionsLoader.LiveAuthorizationEnvironmentVariable, null);
var authorization = new EnvironmentLiveAuthorization();
environment.Set(
PlayoutOptionsLoader.LiveAuthorizationEnvironmentVariable,
PlayoutOptionsLoader.RequiredLiveAuthorizationValue);
Assert.False(authorization.IsAuthorizedForThisLaunch);
}
}