@@ -92,6 +92,41 @@ public void Normalize_should_remove_all_value_with_explicit_assignment_of_existi
92
92
93
93
// Teardown
94
94
}
95
+
96
+ [ Fact ]
97
+ public void Should_properly_parse_option_with_equals_in_value ( )
98
+ {
99
+ /**
100
+ * This is how the arg. would look in `static void Main(string[] args)`
101
+ * if passed from the command-line and the option-value wrapped in quotes.
102
+ * Ex.) ./app --connectionString="Server=localhost;Data Source..."
103
+ */
104
+ var args = new [ ] { "--connectionString=Server=localhost;Data Source=(LocalDB)\v 12.0;Initial Catalog=temp;" } ;
105
+
106
+ var result = Tokenizer . Tokenize ( args , name => NameLookupResult . OtherOptionFound , token => token ) ;
107
+
108
+ var tokens = result . SucceededWith ( ) ;
109
+
110
+ Assert . NotNull ( tokens ) ;
111
+ Assert . Equal ( 2 , tokens . Count ( ) ) ;
112
+ Assert . Equal ( "connectionString" , tokens . First ( ) . Text ) ;
113
+ Assert . Equal ( "Server=localhost;Data Source=(LocalDB)\v 12.0;Initial Catalog=temp;" , tokens . Last ( ) . Text ) ;
114
+ }
115
+
116
+ [ Fact ]
117
+ public void Should_return_error_if_option_format_with_equals_is_not_correct ( )
118
+ {
119
+ var args = new [ ] { "--option1 = fail" , "--option2= fail" } ;
120
+
121
+ var result = Tokenizer . Tokenize ( args , name => NameLookupResult . OtherOptionFound , token => token ) ;
122
+
123
+ var tokens = result . SuccessfulMessages ( ) ;
124
+
125
+ Assert . NotNull ( tokens ) ;
126
+ Assert . Equal ( 2 , tokens . Count ( ) ) ;
127
+ Assert . Equal ( ErrorType . BadFormatTokenError , tokens . First ( ) . Tag ) ;
128
+ Assert . Equal ( ErrorType . BadFormatTokenError , tokens . Last ( ) . Tag ) ;
129
+ }
95
130
}
96
131
97
132
}
0 commit comments