mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 20:18:05 +00:00
feat(subscriptions): update event subscription handling to use non-nullable source parameters; remove defensive null checks
This commit is contained in:
@@ -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
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user