1+ using System . Collections . Generic ;
2+ using System . Linq ;
3+ using FluentAssertions ;
4+ using Xunit ;
5+
6+ namespace Solid . Core . Tests
7+ {
8+ public class PatternsCalculatorTests
9+ {
10+ public class InputData
11+ {
12+ public InputData ( string [ ] prefixes , string [ ] namespaces , string [ ] extensions )
13+ {
14+ Prefixes = prefixes ;
15+ Namespaces = namespaces ;
16+ Extensions = extensions ;
17+ }
18+
19+ public string [ ] Prefixes { get ; }
20+ public string [ ] Namespaces { get ; }
21+ public string [ ] Extensions { get ; }
22+ }
23+
24+ public static IEnumerable < object [ ] > NonEmptyCollectionsData =>
25+ new List < object [ ] >
26+ {
27+ new object [ ]
28+ {
29+ new InputData ( new [ ] { "Prefix" } , new [ ] { "Namespace" } , new [ ] { "ext" } ) ,
30+ new [ ] { new PatternDescription ( "Prefix" , "Namespace" , "ext" ) }
31+ } ,
32+ new object [ ]
33+ {
34+ new InputData ( new [ ] { "Prefix" } , new [ ] { "Namespace1" , "Namespace2" } , new [ ] { "ext" } ) ,
35+ new [ ]
36+ {
37+ new PatternDescription ( "Prefix" , "Namespace1" , "ext" ) ,
38+ new PatternDescription ( "Prefix" , "Namespace2" , "ext" )
39+ }
40+ } ,
41+ new object [ ]
42+ {
43+ new InputData ( new [ ] { "Prefix" } , new [ ] { "Namespace1" , "Namespace2" } , new [ ] { "ext1" , "ext2" } ) ,
44+ new [ ]
45+ {
46+ new PatternDescription ( "Prefix" , "Namespace1" , "ext1" ) ,
47+ new PatternDescription ( "Prefix" , "Namespace1" , "ext2" ) ,
48+ new PatternDescription ( "Prefix" , "Namespace2" , "ext1" ) ,
49+ new PatternDescription ( "Prefix" , "Namespace2" , "ext2" )
50+ }
51+ } ,
52+ new object [ ]
53+ {
54+ new InputData ( new [ ] { "Prefix1" , "Prefix2" } , new [ ] { "Namespace1" , "Namespace2" } , new [ ] { "ext1" , "ext2" } ) ,
55+ new [ ]
56+ {
57+ new PatternDescription ( "Prefix1" , "Namespace1" , "ext1" ) ,
58+ new PatternDescription ( "Prefix1" , "Namespace1" , "ext2" ) ,
59+ new PatternDescription ( "Prefix1" , "Namespace2" , "ext1" ) ,
60+ new PatternDescription ( "Prefix1" , "Namespace2" , "ext2" ) ,
61+ new PatternDescription ( "Prefix2" , "Namespace1" , "ext1" ) ,
62+ new PatternDescription ( "Prefix2" , "Namespace1" , "ext2" ) ,
63+ new PatternDescription ( "Prefix2" , "Namespace2" , "ext1" ) ,
64+ new PatternDescription ( "Prefix2" , "Namespace2" , "ext2" )
65+ }
66+ }
67+ } ;
68+
69+ public static IEnumerable < object [ ] > EmptyCollectionsData =>
70+ new List < object [ ] >
71+ {
72+ new object [ ]
73+ {
74+ new InputData ( new string [ ] { } , new [ ] { "Namespace" } , new [ ] { "ext" } ) ,
75+ new [ ] { new PatternDescription ( "*" , "Namespace" , "ext" ) }
76+ } ,
77+ new object [ ]
78+ {
79+ new InputData ( null , new [ ] { "Namespace" } , new [ ] { "ext" } ) ,
80+ new [ ] { new PatternDescription ( "*" , "Namespace" , "ext" ) }
81+ } ,
82+ new object [ ]
83+ {
84+ new InputData ( new string [ ] { } , new string [ ] { } , new [ ] { "ext" } ) ,
85+ new [ ] { new PatternDescription ( "*" , "*" , "ext" ) }
86+ } ,
87+ new object [ ]
88+ {
89+ new InputData ( null , null , new [ ] { "ext" } ) ,
90+ new [ ] { new PatternDescription ( "*" , "*" , "ext" ) }
91+ } ,
92+ new object [ ]
93+ {
94+ new InputData ( new string [ ] { } , new string [ ] { } , new string [ ] { } ) ,
95+ new [ ] { new PatternDescription ( "*" , "*" , "*" ) }
96+ } ,
97+ new object [ ]
98+ {
99+ new InputData ( null , null , null ) ,
100+ new [ ] { new PatternDescription ( "*" , "*" , "*" ) }
101+ }
102+ } ;
103+
104+ [ Theory ]
105+ [ MemberData ( nameof ( NonEmptyCollectionsData ) ) ]
106+ [ MemberData ( nameof ( EmptyCollectionsData ) ) ]
107+ public void Calculate_VariousInputsAreSupplied_ExpectedOutputsAreReturned ( InputData input ,
108+ PatternDescription [ ] expectedOutput )
109+ {
110+ var searcher = new PatternsCalculator ( ) ;
111+ var paths = searcher . Calculate ( input . Prefixes , input . Namespaces , input . Extensions ) . ToArray ( ) ;
112+
113+ paths . Should ( ) . BeEquivalentTo ( expectedOutput ) ;
114+ }
115+ }
116+ }
0 commit comments