1+ using System . Collections . Generic ;
2+ using GitCredentialManager . Interop . Linux ;
3+ using GitCredentialManager . Tests . Objects ;
4+ using Xunit ;
5+
6+ namespace GitCredentialManager . Tests . Interop . Linux ;
7+
8+ public class LinuxConfigParserTests
9+ {
10+ [ Fact ]
11+ public void LinuxConfigParser_Parse ( )
12+ {
13+ const string contents =
14+ """
15+ #
16+ # This is a config file complete with comments
17+ # and empty..
18+
19+ # lines, as well as lines with..
20+ #
21+ # only whitespace (like above ^), and..
22+ invalid lines like this one, not a comment
23+ # Here's the first real properties:
24+ core.overrideMe=This is the first config value
25+ baz.specialChars=I contain special chars like = in my value # this is a comment
26+ # and let's have with a comment that also contains a = in side
27+ #
28+ core.overrideMe=This is the second config value
29+ bar.scope.foo=123456
30+ core.overrideMe=This is the correct value
31+ ###### comments that start ## with whitespace and extra ## inside
32+ strings.one="here we have a dq string"
33+ strings.two='here we have a sq string'
34+ strings.three= 'here we have another sq string' # have another sq string
35+ strings.four="this has 'nested quotes' inside"
36+ strings.five='mixed "quotes" the other way around'
37+ strings.six='this has an \'escaped\' set of quotes'
38+ """ ;
39+
40+ var expected = new Dictionary < string , string >
41+ {
42+ [ "core.overrideMe" ] = "This is the correct value" ,
43+ [ "bar.scope.foo" ] = "123456" ,
44+ [ "baz.specialChars" ] = "I contain special chars like = in my value" ,
45+ [ "strings.one" ] = "here we have a dq string" ,
46+ [ "strings.two" ] = "here we have a sq string" ,
47+ [ "strings.three" ] = "here we have another sq string" ,
48+ [ "strings.four" ] = "this has 'nested quotes' inside" ,
49+ [ "strings.five" ] = "mixed \" quotes\" the other way around" ,
50+ [ "strings.six" ] = "this has an \\ 'escaped\\ ' set of quotes" ,
51+ } ;
52+
53+ var parser = new LinuxConfigParser ( new NullTrace ( ) ) ;
54+
55+ Assert . Equal ( expected , parser . Parse ( contents ) ) ;
56+ }
57+ }
0 commit comments