feat(subscriptions): update event subscription handling to use non-nullable source parameters; remove defensive null checks

This commit is contained in:
Miha Kralj
2025-12-26 13:34:21 -08:00
parent 47488985e1
commit 618837dc27
12 changed files with 14 additions and 24 deletions
+1 -2
View File
@@ -25,8 +25,7 @@ public class BlmaTests
[Fact]
public void Constructor_ValidatesSource()
{
Assert.Throws<ArgumentNullException>(() => new Blma(null!, 10));
Assert.Throws<ArgumentException>(() => new Blma(new object(), 10));
Assert.Throws<NullReferenceException>(() => new Blma(null!, 10));
}
[Fact]
+3 -12
View File
@@ -33,19 +33,10 @@ public sealed class Blma : AbstractBase, IDisposable
_weightSum = CalculateWeights(period, _weights);
}
public Blma(object source, int period) : this(period)
public Blma(ITValuePublisher source, int period) : this(period)
{
ArgumentNullException.ThrowIfNull(source);
if (source is ITValuePublisher pub)
{
_publisher = pub;
_publisher.Pub += Handle;
}
else
{
throw new ArgumentException("Source must implement ITValuePublisher", nameof(source));
}
_publisher = source;
source.Pub += Handle;
}
public void Dispose()