|
1 | 1 | namespace BufferLists; |
2 | 2 |
|
3 | 3 | [TestClass] |
4 | | -public class Ichimoku : BufferListTestBase, ITestQuoteBufferList |
| 4 | +public class Ichimoku : BufferListTestBase, ITestQuoteBufferList, ITestCustomBufferListCache |
5 | 5 | { |
6 | 6 | private const int tenkanPeriods = 9; |
7 | 7 | private const int kijunPeriods = 26; |
@@ -82,4 +82,31 @@ IReadOnlyList<IchimokuResult> expected |
82 | 82 | sut.Should().HaveCount(maxListSize); |
83 | 83 | sut.Should().BeEquivalentTo(expected, static options => options.WithStrictOrdering()); |
84 | 84 | } |
| 85 | + |
| 86 | + [TestMethod] |
| 87 | + public void CustomBuffer_OverMaxListSize_AutoAdjustsListAndBuffers() |
| 88 | + { |
| 89 | + const int maxListSize = 150; |
| 90 | + const int quotesSize = 1000; |
| 91 | + |
| 92 | + // Use a test data that exceeds all cache size thresholds |
| 93 | + List<Quote> quotes = LongishQuotes |
| 94 | + .Take(quotesSize) |
| 95 | + .ToList(); |
| 96 | + |
| 97 | + // Expected results after pruning (tail end) |
| 98 | + IReadOnlyList<IchimokuResult> expected = quotes |
| 99 | + .ToIchimoku(tenkanPeriods, kijunPeriods, senkouBPeriods, senkouOffset, chikouOffset) |
| 100 | + .Skip(quotesSize - maxListSize) |
| 101 | + .ToList(); |
| 102 | + |
| 103 | + // Generate buffer list |
| 104 | + IchimokuList sut = new(tenkanPeriods, kijunPeriods, senkouBPeriods, senkouOffset, chikouOffset, quotes) { |
| 105 | + MaxListSize = maxListSize |
| 106 | + }; |
| 107 | + |
| 108 | + // Verify expected results matching equivalent series values |
| 109 | + sut.Count.Should().Be(maxListSize); |
| 110 | + sut.Should().BeEquivalentTo(expected, static options => options.WithStrictOrdering()); |
| 111 | + } |
85 | 112 | } |
0 commit comments