1
+ using System . Collections . Generic ;
2
+ using Xunit ;
3
+
4
+ namespace Day018 . Test ;
5
+
6
+ public abstract class StrategyTestBase
7
+ {
8
+ private readonly IStrategy _strategy ;
9
+
10
+ protected StrategyTestBase ( IStrategy strategy )
11
+ {
12
+ _strategy = strategy ;
13
+ }
14
+
15
+ [ Theory ]
16
+ [ InlineData ( new [ ] { 10 , 5 , 2 , 7 , 8 , 7 } , 1 , new [ ] { 10 , 5 , 2 , 7 , 8 , 7 } ) ]
17
+ [ InlineData ( new [ ] { 10 , 5 , 2 , 7 , 8 , 7 } , 2 , new [ ] { 10 , 5 , 7 , 8 , 8 } ) ]
18
+ [ InlineData ( new [ ] { 10 , 5 , 2 , 7 , 8 , 7 } , 3 , new [ ] { 10 , 7 , 8 , 8 } ) ]
19
+ [ InlineData ( new [ ] { 10 , 5 , 2 , 7 , 8 , 7 } , 4 , new [ ] { 10 , 8 , 8 } ) ]
20
+ [ InlineData ( new [ ] { 10 , 5 , 2 , 7 , 8 , 7 } , 6 , new [ ] { 10 } ) ]
21
+ [ InlineData ( new [ ] { 1 , 1 , 1 , 1 , 1 , 1 } , 1 , new [ ] { 1 , 1 , 1 , 1 , 1 , 1 } ) ]
22
+ [ InlineData ( new [ ] { 1 , 1 , 1 , 1 , 1 , 1 } , 2 , new [ ] { 1 , 1 , 1 , 1 , 1 } ) ]
23
+ [ InlineData ( new [ ] { 1 , 1 , 1 , 1 , 1 , 1 } , 3 , new [ ] { 1 , 1 , 1 , 1 } ) ]
24
+ [ InlineData ( new [ ] { 1 , 1 , 1 , 1 , 1 , 1 } , 6 , new [ ] { 1 } ) ]
25
+ [ InlineData ( new [ ] { 1 , 2 , 3 , 10 , 2 , 5 , - 4 , - 7 , - 2 , 10 } , 3 ,
26
+ new [ ] { 3 , 10 , 10 , 10 , 5 , 5 , - 2 , 10 } ) ]
27
+ public void Execute_GivenIntArrayAndSubsetLength_ReturnsMaxOfRollingSubsets (
28
+ int [ ] inputList , int subsetLength , int [ ] expected )
29
+ {
30
+ var actual = new List < int > ( ) ;
31
+
32
+ _strategy . Execute ( inputList , subsetLength , actual ) ;
33
+
34
+ Assert . Equal ( expected , actual ) ;
35
+ }
36
+ }
0 commit comments