@@ -321,4 +321,138 @@ public void girocode_generator_sets_encoding_parameters()
321321 payload . EciMode . ShouldBe < EciMode > ( EciMode . Default ) ;
322322 payload . Version . ShouldBe ( - 1 ) ;
323323 }
324+
325+ [ Fact ]
326+ public void girocode_generator_version2_with_null_bic_should_succeed ( )
327+ {
328+ var iban = "NL86INGB0002445588" ;
329+ var name = "a name" ;
330+ var remittanceInformation = "some info" ;
331+ var amount = 1337.99m ;
332+
333+ var payload = new PayloadGenerator . Girocode (
334+ iban : iban ,
335+ bic : null ,
336+ name : name ,
337+ amount : amount ,
338+ remittanceInformation : remittanceInformation ,
339+ version : PayloadGenerator . Girocode . GirocodeVersion . Version2 ,
340+ encoding : PayloadGenerator . Girocode . GirocodeEncoding . UTF_8 ) ;
341+
342+ payload
343+ . ToString ( )
344+ . ShouldBe ( "BCD\n 002\n 1\n SCT\n \n a name\n NL86INGB0002445588\n EUR1337.99\n \n \n some info\n " ) ;
345+ }
346+
347+ [ Fact ]
348+ public void girocode_generator_version2_with_empty_bic_should_succeed ( )
349+ {
350+ var iban = "NL86INGB0002445588" ;
351+ var name = "a name" ;
352+ var remittanceInformation = "some info" ;
353+ var amount = 1337.99m ;
354+
355+ var payload = new PayloadGenerator . Girocode (
356+ iban : iban ,
357+ bic : string . Empty ,
358+ name : name ,
359+ amount : amount ,
360+ remittanceInformation : remittanceInformation ,
361+ version : PayloadGenerator . Girocode . GirocodeVersion . Version2 ,
362+ encoding : PayloadGenerator . Girocode . GirocodeEncoding . UTF_8 ) ;
363+
364+ payload
365+ . ToString ( )
366+ . ShouldBe ( "BCD\n 002\n 1\n SCT\n \n a name\n NL86INGB0002445588\n EUR1337.99\n \n \n some info\n " ) ;
367+ }
368+
369+ [ Fact ]
370+ public void girocode_generator_version2_with_valid_bic_should_succeed ( )
371+ {
372+ var iban = "NL86INGB0002445588" ;
373+ var bic = "INGBNL2A" ;
374+ var name = "a name" ;
375+ var remittanceInformation = "some info" ;
376+ var amount = 1337.99m ;
377+
378+ var payload = new PayloadGenerator . Girocode (
379+ iban : iban ,
380+ bic : bic ,
381+ name : name ,
382+ amount : amount ,
383+ remittanceInformation : remittanceInformation ,
384+ version : PayloadGenerator . Girocode . GirocodeVersion . Version2 ,
385+ encoding : PayloadGenerator . Girocode . GirocodeEncoding . UTF_8 ) ;
386+
387+ payload
388+ . ToString ( )
389+ . ShouldBe ( "BCD\n 002\n 1\n SCT\n INGBNL2A\n a name\n NL86INGB0002445588\n EUR1337.99\n \n \n some info\n " ) ;
390+ }
391+
392+ [ Fact ]
393+ public void girocode_generator_version2_with_invalid_bic_should_throw_exception ( )
394+ {
395+ var iban = "NL86INGB0002445588" ;
396+ var bic = "INVALID" ;
397+ var name = "a name" ;
398+ var remittanceInformation = "some info" ;
399+ var amount = 1337.99m ;
400+
401+ var exception = Record . Exception ( ( ) => new PayloadGenerator . Girocode (
402+ iban : iban ,
403+ bic : bic ,
404+ name : name ,
405+ amount : amount ,
406+ remittanceInformation : remittanceInformation ,
407+ version : PayloadGenerator . Girocode . GirocodeVersion . Version2 ,
408+ encoding : PayloadGenerator . Girocode . GirocodeEncoding . UTF_8 ) ) ;
409+
410+ Assert . NotNull ( exception ) ;
411+ Assert . IsType < PayloadGenerator . Girocode . GirocodeException > ( exception ) ;
412+ exception . Message . ShouldBe ( "The BIC entered isn't valid." ) ;
413+ }
414+
415+ [ Fact ]
416+ public void girocode_generator_version1_with_null_bic_should_throw_exception ( )
417+ {
418+ var iban = "NL86INGB0002445588" ;
419+ var name = "a name" ;
420+ var remittanceInformation = "some info" ;
421+ var amount = 1337.99m ;
422+
423+ var exception = Record . Exception ( ( ) => new PayloadGenerator . Girocode (
424+ iban : iban ,
425+ bic : null ,
426+ name : name ,
427+ amount : amount ,
428+ remittanceInformation : remittanceInformation ,
429+ version : PayloadGenerator . Girocode . GirocodeVersion . Version1 ,
430+ encoding : PayloadGenerator . Girocode . GirocodeEncoding . UTF_8 ) ) ;
431+
432+ Assert . NotNull ( exception ) ;
433+ Assert . IsType < PayloadGenerator . Girocode . GirocodeException > ( exception ) ;
434+ exception . Message . ShouldBe ( "The BIC entered isn't valid." ) ;
435+ }
436+
437+ [ Fact ]
438+ public void girocode_generator_version1_with_empty_bic_should_throw_exception ( )
439+ {
440+ var iban = "NL86INGB0002445588" ;
441+ var name = "a name" ;
442+ var remittanceInformation = "some info" ;
443+ var amount = 1337.99m ;
444+
445+ var exception = Record . Exception ( ( ) => new PayloadGenerator . Girocode (
446+ iban : iban ,
447+ bic : string . Empty ,
448+ name : name ,
449+ amount : amount ,
450+ remittanceInformation : remittanceInformation ,
451+ version : PayloadGenerator . Girocode . GirocodeVersion . Version1 ,
452+ encoding : PayloadGenerator . Girocode . GirocodeEncoding . UTF_8 ) ) ;
453+
454+ Assert . NotNull ( exception ) ;
455+ Assert . IsType < PayloadGenerator . Girocode . GirocodeException > ( exception ) ;
456+ exception . Message . ShouldBe ( "The BIC entered isn't valid." ) ;
457+ }
324458}
0 commit comments