feat: update Qodana configuration to disable failure conditions and improve build stability

refactor: enhance Bilateral and SMA indicators to handle edge cases and improve state management
refactor: clean up whitespace and formatting in various test files for consistency
This commit is contained in:
Miha Kralj
2025-12-28 16:22:45 -08:00
parent 5c3b3fbab4
commit 14c5f21d9e
50 changed files with 111 additions and 77 deletions
+31
View File
@@ -106,6 +106,37 @@ public class BilateralTests
Assert.False(indicator.IsHot);
Assert.Equal(1, indicator.Update(new TValue(DateTime.UtcNow, 1)).Value); // Center val 1, weights 0? No, center val is returned if weights 0.
}
[Fact]
public void Update_IsNew_False_OnEmptyBuffer_DoesNotCrash()
{
// Test edge case: calling Update with isNew:false before any isNew:true
var indicator = new Bilateral(3);
// This should not crash - buffer is empty, so we treat it as first value
var result = indicator.Update(new TValue(DateTime.UtcNow, 5.0), isNew: false);
// Should have added the value to the buffer
Assert.True(double.IsFinite(result.Value));
Assert.Equal(5.0, result.Value); // Single value, so result is that value
}
[Fact]
public void Update_IsNew_False_AfterReset_DoesNotCrash()
{
// Test edge case: calling Update with isNew:false after Reset
var indicator = new Bilateral(3);
indicator.Update(new TValue(DateTime.UtcNow, 1));
indicator.Update(new TValue(DateTime.UtcNow, 2));
indicator.Reset();
// Buffer is now empty, isNew:false should not crash
var result = indicator.Update(new TValue(DateTime.UtcNow, 7.0), isNew: false);
Assert.True(double.IsFinite(result.Value));
Assert.Equal(7.0, result.Value);
}
[Fact]
public void AllModes_ProduceSameResult()