1+ using  System ; 
12using  Tomlet . Models ; 
3+ using  Tomlet . Tests . CommentProvider ; 
24using  Tomlet . Tests . TestModelClasses ; 
35using  Xunit ; 
6+ using  Xunit . Abstractions ; 
47
58namespace  Tomlet . Tests ; 
69
@@ -72,7 +75,7 @@ public void CommentsOnTableArraysWork()
7275        tomlString . Comments . InlineComment  =  "Inline comment on value" ; 
7376        table . PutValue ( "key" ,  tomlString ) ; 
7477
75-         var  tableArray  =  new  TomlArray  { table } ; 
78+         var  tableArray  =  new  TomlArray  {   table   } ; 
7679        tableArray . Comments . PrecedingComment  =  "This is a preceding comment on the table-array itself" ; 
7780
7881        doc . PutValue ( "table-array" ,  tableArray ) ; 
@@ -91,7 +94,7 @@ public void CommentsOnTableArraysWork()
9194    public  void  CommentsOnPrimitiveArraysWork ( ) 
9295    { 
9396        var  doc  =  TomlDocument . CreateEmpty ( ) ; 
94-         var  tomlNumbers  =  new  TomlArray  { 1 ,  2 ,  3 } ; 
97+         var  tomlNumbers  =  new  TomlArray  {   1 ,  2 ,  3   } ; 
9598        doc . PutValue ( "numbers" ,  tomlNumbers ) ; 
9699
97100        tomlNumbers [ 0 ] . Comments . PrecedingComment  =  "This is a preceding comment on the first value of the array" ; 
@@ -103,7 +106,7 @@ public void CommentsOnPrimitiveArraysWork()
103106    2, # This is an inline comment on the second value of the array 
104107    3, 
105108]" . ReplaceLineEndings ( ) ; 
106-          
109+ 
107110        //Replace tabs with spaces because this source file uses spaces 
108111        var  actual  =  doc . SerializedValue . Trim ( ) . Replace ( "\t " ,  "    " ) . ReplaceLineEndings ( ) ; 
109112        Assert . Equal ( expected ,  actual ) ; 
@@ -115,10 +118,33 @@ public void CommentAttributesWork()
115118        var  config  =  TomletMain . To < ExampleMailboxConfigClass > ( TestResources . ExampleMailboxConfigurationTestInput ) ; 
116119
117120        var  doc  =  TomletMain . DocumentFrom ( config ) ; 
118-          
121+ 
119122        Assert . Equal ( "The name of the mailbox" ,  doc . GetValue ( "mailbox" ) . Comments . InlineComment ) ; 
120123        Assert . Equal ( "Your username for the mailbox" ,  doc . GetValue ( "username" ) . Comments . InlineComment ) ; 
121124        Assert . Equal ( "The password you use to access the mailbox" ,  doc . GetValue ( "password" ) . Comments . InlineComment ) ; 
122125        Assert . Equal ( "The rules for the mailbox follow" ,  doc . GetArray ( "rules" ) . Comments . PrecedingComment ) ; 
123126    } 
127+ 
128+     [ Fact ] 
129+     public  void  CommentProviderTest ( ) 
130+     { 
131+         TestPrecedingCommentProvider . Comments [ "PrecedingComment" ]  =  Guid . NewGuid ( ) . ToString ( ) ; 
132+         TestInlineCommentProvider . Comments [ "InlineComment" ]  =  Guid . NewGuid ( ) . ToString ( ) ; 
133+ 
134+         var  data  =  new  CommentProviderTestModel ( ) 
135+         { 
136+             PrecedingComment  =  "Dynamic Preceding Comment" , 
137+             InlineComment  =  "Inline Comment" , 
138+         } ; 
139+ 
140+         var  doc  =  TomletMain . DocumentFrom ( data ) ; 
141+ 
142+         Assert . Equal ( TestPrecedingCommentProvider . Comments [ "PrecedingComment" ] , 
143+             doc . GetValue ( "PrecedingComment" ) . Comments . PrecedingComment ) ; 
144+         Assert . Equal ( "PlainInlineComment" ,  doc . GetValue ( "PrecedingComment" ) . Comments . InlineComment ) ; 
145+ 
146+         Assert . Equal ( TestInlineCommentProvider . Comments [ "InlineComment" ] , 
147+             doc . GetValue ( "InlineComment" ) . Comments . InlineComment ) ; 
148+         Assert . Equal ( "PlainPrecedingComment" ,  doc . GetValue ( "InlineComment" ) . Comments . PrecedingComment ) ; 
149+     } 
124150} 
0 commit comments