File tree Expand file tree Collapse file tree
RuriLib.Tests/Models/Hits Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,32 @@ public void Hit_CapturedDataString_UsesNullFallback()
4141 Assert . Equal ( "TOKEN = null" , hit . CapturedDataString ) ;
4242 }
4343
44+ [ Fact ]
45+ public void Hit_ToString_OmitsSeparatorWhenCapturedDataIsEmpty ( )
46+ {
47+ var hit = new Hit
48+ {
49+ Data = new DataLine ( "user:pass" , new WordlistType ( ) )
50+ } ;
51+
52+ Assert . Equal ( "user:pass" , hit . ToString ( ) ) ;
53+ }
54+
55+ [ Fact ]
56+ public void Hit_ToString_JoinsDataAndCapturedDataWhenBothArePresent ( )
57+ {
58+ var hit = new Hit
59+ {
60+ Data = new DataLine ( "user:pass" , new WordlistType ( ) ) ,
61+ CapturedData = new Dictionary < string , object >
62+ {
63+ [ "TOKEN" ] = "abc"
64+ }
65+ } ;
66+
67+ Assert . Equal ( "user:pass | TOKEN = abc" , hit . ToString ( ) ) ;
68+ }
69+
4470 [ Fact ]
4571 public async Task FileSystemHitOutput_Store_WritesUsingEnvironmentNewLine ( )
4672 {
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ public class Hit
4646 /// Returns a compact string representation of the hit.
4747 /// </summary>
4848 /// <returns>The formatted hit string.</returns>
49- public override string ToString ( ) => $ "{ DataString } | { CapturedDataString } ";
49+ public override string ToString ( )
50+ => string . Join ( " | " , new [ ] { DataString , CapturedDataString } . Where ( s => ! string . IsNullOrEmpty ( s ) ) ) ;
5051
5152 private string ConvertCapturedData ( )
5253 {
You can’t perform that action at this time.
0 commit comments