42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using ZB.MOM.WW.ScadaBridge.AuditLog.Central;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.Central;
|
|
|
|
/// <summary>
|
|
/// Eager startup validation for <see cref="AuditLogPartitionMaintenanceOptions"/>
|
|
/// (arch-review 08 round 2 NF4). A zero tick interval spins the maintenance
|
|
/// hosted service; a zero look-ahead leaves the partition function without a
|
|
/// future monthly boundary, risking inserts into the unbounded tail partition.
|
|
/// </summary>
|
|
public class AuditLogPartitionMaintenanceOptionsValidatorTests
|
|
{
|
|
[Fact]
|
|
public void DefaultOptions_AreValid()
|
|
{
|
|
var validator = new AuditLogPartitionMaintenanceOptionsValidator();
|
|
Assert.True(validator.Validate(null, new AuditLogPartitionMaintenanceOptions()).Succeeded);
|
|
}
|
|
|
|
[Fact]
|
|
public void ZeroIntervalSeconds_Fails()
|
|
{
|
|
var validator = new AuditLogPartitionMaintenanceOptionsValidator();
|
|
var result = validator.Validate(null,
|
|
new AuditLogPartitionMaintenanceOptions { IntervalSeconds = 0 });
|
|
Assert.False(result.Succeeded);
|
|
Assert.Contains(result.Failures!,
|
|
f => f.Contains(nameof(AuditLogPartitionMaintenanceOptions.IntervalSeconds), StringComparison.Ordinal));
|
|
}
|
|
|
|
[Fact]
|
|
public void ZeroLookaheadMonths_Fails()
|
|
{
|
|
var validator = new AuditLogPartitionMaintenanceOptionsValidator();
|
|
var result = validator.Validate(null,
|
|
new AuditLogPartitionMaintenanceOptions { LookaheadMonths = 0 });
|
|
Assert.False(result.Succeeded);
|
|
Assert.Contains(result.Failures!,
|
|
f => f.Contains(nameof(AuditLogPartitionMaintenanceOptions.LookaheadMonths), StringComparison.Ordinal));
|
|
}
|
|
}
|