@@ -48,15 +48,7 @@ public void OneTimeTearDown()
4848
4949 ComfyGateway CreateGateway ( ) => new ( NullLogger < ComfyGateway > . Instance , serviceProvider . GetRequiredService < IHttpClientFactory > ( ) , ComfyMetadata . Instance ) ;
5050
51- public static string FormatJson ( string json )
52- {
53- using JsonDocument document = JsonDocument . Parse ( json ) ;
54- string formattedJson = System . Text . Json . JsonSerializer . Serialize ( document , new JsonSerializerOptions {
55- WriteIndented = true
56- } ) ;
57- return formattedJson ;
58- }
59- public static void DumpJson ( string json ) => Console . WriteLine ( FormatJson ( json ) ) ;
51+ public static void DumpJson ( string json ) => Console . WriteLine ( ClientConfig . IndentJson ( json ) ) ;
6052
6153 private static bool UseNode = true ;
6254
@@ -185,10 +177,10 @@ public void Can_execute_sdxl_base_refiner_ComfyUI_API_prompt()
185177 {
186178 var apiPromptFullPath = Path . Combine ( AppContext . BaseDirectory , $ "../../../workflows/prompts/sdxl_base_refiner.api-prompt.json") ;
187179 var promptJson = File . ReadAllText ( apiPromptFullPath ) ;
188- // Console.WriteLine (promptJson);
180+ // DumpJson (promptJson);
189181
190182 var responseJson = ExecutePrompt ( promptJson ) . Result ;
191- Console . WriteLine ( responseJson ) ;
183+ DumpJson ( responseJson ) ;
192184 }
193185
194186 /// <summary>
@@ -201,7 +193,7 @@ public async Task Can_execute_sdxl_base_refiner_Workflow()
201193 // Use the API prompt directly from the file instead of converting the workflow
202194 var apiPromptFullPath = Path . Combine ( AppContext . BaseDirectory , $ "../../../workflows/prompts/sdxl_base_refiner.api-prompt.json") ;
203195 var promptJson = File . ReadAllText ( apiPromptFullPath ) ;
204- // Console.WriteLine (promptJson);
196+ // DumpJson (promptJson);
205197
206198 // Verify the JSON is valid and contains expected elements
207199 var jsonNode = JsonNode . Parse ( promptJson ) ;
@@ -238,7 +230,7 @@ public async Task Can_execute_sdxl_base_refiner_Workflow()
238230 Assert . That ( node11 [ "sampler_name" ] . GetValue < string > ( ) , Is . EqualTo ( "euler" ) , "sampler_name should be 'euler'" ) ;
239231
240232 // var responseJson = await ExecutePrompt(promptJson);
241- // Console.WriteLine (responseJson);
233+ // DumpJson (responseJson);
242234 }
243235
244236 [ Test ]
@@ -261,37 +253,37 @@ public async Task Can_execute_DreamshaperXL_Workflow()
261253 var promptJson = await CreateApiPromptJson ( "text-to-image/dreamshaperXL.json" ) ;
262254
263255 var responseJson = await ExecutePrompt ( promptJson ) ;
264- Console . WriteLine ( responseJson ) ;
256+ DumpJson ( responseJson ) ;
265257 }
266258
267259 [ Test ]
268260 public async Task Can_execute_FluxSchnell_Workflow ( )
269261 {
270262 var promptJson = await CreateApiPromptJson ( "text-to-image/flux1-schnell.json" ) ;
271- Console . WriteLine ( promptJson ) ;
263+ DumpJson ( promptJson ) ;
272264
273265 var responseJson = await ExecutePrompt ( promptJson ) ;
274- Console . WriteLine ( responseJson ) ;
266+ DumpJson ( responseJson ) ;
275267 }
276268
277269 [ Test ]
278270 public async Task Can_execute_Hidream_Dev_Workflow ( )
279271 {
280272 var promptJson = await CreateApiPromptJson ( "text-to-image/hidream_i1_dev_fp8.json" ) ;
281- Console . WriteLine ( promptJson ) ;
273+ DumpJson ( promptJson ) ;
282274
283275 var responseJson = await ExecutePrompt ( promptJson ) ;
284- Console . WriteLine ( responseJson ) ;
276+ DumpJson ( responseJson ) ;
285277 }
286278
287279 [ Test ]
288280 public async Task Can_execute_JibMixRealisticXL_Workflow ( )
289281 {
290282 var promptJson = await CreateApiPromptJson ( "text-to-image/jibMixRealisticXL.json" ) ;
291- Console . WriteLine ( promptJson ) ;
283+ DumpJson ( promptJson ) ;
292284
293285 var responseJson = await ExecutePrompt ( promptJson ) ;
294- Console . WriteLine ( responseJson ) ;
286+ DumpJson ( responseJson ) ;
295287 }
296288
297289 [ Test ]
@@ -308,115 +300,115 @@ public async Task Can_execute_JibMixRealisticXL_v18_Workflow()
308300 public async Task Can_execute_JuggernautXL_Workflow ( )
309301 {
310302 var promptJson = await CreateApiPromptJson ( "text-to-image/juggernautXL.json" ) ;
311- Console . WriteLine ( promptJson ) ;
303+ DumpJson ( promptJson ) ;
312304
313305 var responseJson = await ExecutePrompt ( promptJson ) ;
314- Console . WriteLine ( responseJson ) ;
306+ DumpJson ( responseJson ) ;
315307 }
316308
317309 [ Test ]
318310 public async Task Can_execute_RealvisXL_Workflow ( )
319311 {
320312 var promptJson = await CreateApiPromptJson ( "text-to-image/realvisxl.json" ) ;
321- Console . WriteLine ( promptJson ) ;
313+ DumpJson ( promptJson ) ;
322314
323315 var responseJson = await ExecutePrompt ( promptJson ) ;
324- Console . WriteLine ( responseJson ) ;
316+ DumpJson ( responseJson ) ;
325317 }
326318
327319 [ Test ]
328320 public async Task Can_execute_SD35_Large_FP8_Workflow ( )
329321 {
330322 var promptJson = await CreateApiPromptJson ( "text-to-image/sd3.5_large_fp8_scaled.json" ) ;
331- Console . WriteLine ( promptJson ) ;
323+ DumpJson ( promptJson ) ;
332324
333325 var responseJson = await ExecutePrompt ( promptJson ) ;
334- Console . WriteLine ( responseJson ) ;
326+ DumpJson ( responseJson ) ;
335327 }
336328
337329 [ Test ]
338330 public async Task Can_execute_SD35_Large_Turbo_Workflow ( )
339331 {
340332 var promptJson = await CreateApiPromptJson ( "text-to-image/sd3.5_large_turbo.json" ) ;
341- Console . WriteLine ( promptJson ) ;
333+ DumpJson ( promptJson ) ;
342334
343335 var responseJson = await ExecutePrompt ( promptJson ) ;
344- Console . WriteLine ( responseJson ) ;
336+ DumpJson ( responseJson ) ;
345337 }
346338
347339 [ Test ]
348340 public async Task Can_execute_SDXL_lightning_Workflow ( )
349341 {
350342 var promptJson = await CreateApiPromptJson ( "text-to-image/sdxl_lightning_4step.json" ) ;
351- Console . WriteLine ( promptJson ) ;
343+ DumpJson ( promptJson ) ;
352344
353345 var responseJson = await ExecutePrompt ( promptJson ) ;
354- Console . WriteLine ( responseJson ) ;
346+ DumpJson ( responseJson ) ;
355347 }
356348
357349 [ Test ]
358350 public async Task Can_execute_Smooth_Workflow ( )
359351 {
360352 var apiPrompt = await CreateApiPrompt ( "text-to-image/smooth_workflow_v3.json" ) ;
361353 var promptJson = ClientConfig . ToSystemJson ( apiPrompt ) ;
362- // Console.WriteLine (promptJson);
354+ // DumpJson (promptJson);
363355
364356 var responseJson = await ExecutePrompt ( promptJson ) ;
365- Console . WriteLine ( responseJson ) ;
357+ DumpJson ( responseJson ) ;
366358 }
367359
368360 [ Ignore ( "Requires Florence2" ) ]
369361 [ Test ]
370362 public async Task Can_execute_Florence2_ImageToText_Workflow ( )
371363 {
372364 var promptJson = await CreateApiPromptJson ( "image-to-text/florence2.json" ) ;
373- Console . WriteLine ( promptJson ) ;
365+ DumpJson ( promptJson ) ;
374366
375367 var responseJson = await ExecutePrompt ( promptJson ) ;
376- Console . WriteLine ( responseJson ) ;
368+ DumpJson ( responseJson ) ;
377369 }
378370
379371 [ Ignore ( "Requires image file: 00134-2415444908.png" ) ]
380372 [ Test ]
381373 public async Task Can_execute_SD15_pruned_emaonly_ImageToImage_Workflow ( )
382374 {
383375 var promptJson = await CreateApiPromptJson ( "image-to-image/sd1.5_pruned_emaonly.json" ) ;
384- Console . WriteLine ( promptJson ) ;
376+ DumpJson ( promptJson ) ;
385377
386378 var responseJson = await ExecutePrompt ( promptJson ) ;
387- Console . WriteLine ( responseJson ) ;
379+ DumpJson ( responseJson ) ;
388380 }
389381
390382 [ Test ]
391383 public async Task Can_execute_VibeVoice_AudioToAudio_Workflow ( )
392384 {
393385 var promptJson = await CreateApiPromptJson ( "audio-to-audio/VibeVoice-SingleSpeaker.json" ) ;
394- Console . WriteLine ( promptJson ) ;
386+ DumpJson ( promptJson ) ;
395387
396388 var responseJson = await ExecutePrompt ( promptJson ) ;
397- Console . WriteLine ( responseJson ) ;
389+ DumpJson ( responseJson ) ;
398390 }
399391
400392 [ Ignore ( "Requires TT-LoadAudio" ) ]
401393 [ Test ]
402394 public async Task Can_execute_SD15_pruned_emaonly_AudioToText_Workflow ( )
403395 {
404396 var promptJson = await CreateApiPromptJson ( "audio-to-text/transcribe-audio-whisper.json" ) ;
405- Console . WriteLine ( promptJson ) ;
397+ DumpJson ( promptJson ) ;
406398
407399 var responseJson = await ExecutePrompt ( promptJson ) ;
408- Console . WriteLine ( responseJson ) ;
400+ DumpJson ( responseJson ) ;
409401 }
410402
411403 [ Ignore ( "Requires TT-LoadAudio" ) ]
412404 [ Test ]
413405 public async Task Can_execute_Transcribe_Whisper_VideoToText_Workflow ( )
414406 {
415407 var promptJson = await CreateApiPromptJson ( "video-to-text/transcribe-video-whisper.json" ) ;
416- Console . WriteLine ( promptJson ) ;
408+ DumpJson ( promptJson ) ;
417409
418410 var responseJson = await ExecutePrompt ( promptJson ) ;
419- Console . WriteLine ( responseJson ) ;
411+ DumpJson ( responseJson ) ;
420412 }
421413
422414 [ Test ]
0 commit comments