@@ -899,22 +899,30 @@ def call_method(instance):
899899 }
900900
901901 [ Test ]
902- public void BindsConstructorToSnakeCasedArgumentsVersion ( )
902+ public void BindsConstructorToSnakeCasedArgumentsVersion ( [ Values ] bool useCamelCase , [ Values ] bool passOptionalArgument )
903903 {
904904 using var _ = Py . GIL ( ) ;
905905
906- var module = PyModule . FromString ( "CallsCorrectOverloadWithoutErrors" , @"
906+ var argument1Name = useCamelCase ? "someArgument" : "some_argument" ;
907+ var argument2Name = useCamelCase ? "anotherArgument" : "another_argument" ;
908+ var argument2Code = passOptionalArgument ? $ ", { argument2Name } =\" another argument value\" " : "" ;
909+
910+ var module = PyModule . FromString ( "CallsCorrectOverloadWithoutErrors" , @$ "
907911from clr import AddReference
908912AddReference(""System"")
909913from Python.EmbeddingTest import *
910914
911915def create_instance():
912- return TestMethodBinder.CSharpModel(some_argument=1, another_argument=""another argument value"" )
916+ return TestMethodBinder.CSharpModel({ argument1Name } =1 { argument2Code } )
913917" ) ;
914918 var exception = Assert . Throws < ClrBubbledException > ( ( ) => module . GetAttr ( "create_instance" ) . Invoke ( ) ) ;
915919 var sourceException = exception . InnerException ;
916920 Assert . IsInstanceOf < NotImplementedException > ( sourceException ) ;
917- Assert . AreEqual ( "Constructor with arguments" , sourceException . Message ) ;
921+
922+ var expectedMessage = passOptionalArgument
923+ ? "Constructor with arguments: someArgument=1. anotherArgument=\" another argument value\" "
924+ : "Constructor with arguments: someArgument=1. anotherArgument=\" another argument default value\" " ;
925+ Assert . AreEqual ( expectedMessage , sourceException . Message ) ;
918926 }
919927
920928 // Used to test that we match this function with Py DateTime & Date Objects
@@ -937,9 +945,9 @@ public CSharpModel()
937945 } ;
938946 }
939947
940- public CSharpModel ( int someArgument , string anotherArgument = "another argument" )
948+ public CSharpModel ( int someArgument , string anotherArgument = "another argument default value " )
941949 {
942- throw new NotImplementedException ( "Constructor with arguments" ) ;
950+ throw new NotImplementedException ( $ "Constructor with arguments: someArgument= { someArgument } . anotherArgument= \" { anotherArgument } \" ") ;
943951 }
944952
945953 public void TestList ( List < TestImplicitConversion > conversions )
0 commit comments