Skip to content

Commit 0acc2db

Browse files
committed
Improve unit test
1 parent 93fb973 commit 0acc2db

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/embed_tests/TestMethodBinder.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,12 @@ def call_method(instance):
925925

926926
public class CSharpClass2
927927
{
928-
public string CalledMethodMessage { get; private set; }
928+
public string CalledMethodMessage { get; private set; } = string.Empty;
929+
930+
public void Clear()
931+
{
932+
CalledMethodMessage = string.Empty;
933+
}
929934

930935
public void Method()
931936
{
@@ -967,13 +972,21 @@ public void PyObjectArgsHavePrecedenceOverOtherTypes()
967972
pyInstance.InvokeMethod("Method", pyArg);
968973
});
969974

975+
Assert.AreEqual("Overload 4", instance.CalledMethodMessage);
976+
Assert.IsFalse(Exceptions.ErrorOccurred());
977+
instance.Clear();
978+
970979
// With the first named argument
971980
Assert.DoesNotThrow(() =>
972981
{
973982
using var kwargs = Py.kw("decimalArgument", 1.234m);
974983
pyInstance.InvokeMethod("Method", new[] { pyArg }, kwargs);
975984
});
976985

986+
Assert.AreEqual("Overload 4", instance.CalledMethodMessage);
987+
Assert.IsFalse(Exceptions.ErrorOccurred());
988+
instance.Clear();
989+
977990
// Snake case version
978991
Assert.DoesNotThrow(() =>
979992
{
@@ -982,7 +995,6 @@ public void PyObjectArgsHavePrecedenceOverOtherTypes()
982995
});
983996

984997
Assert.AreEqual("Overload 4", instance.CalledMethodMessage);
985-
986998
Assert.IsFalse(Exceptions.ErrorOccurred());
987999
}
9881000

0 commit comments

Comments
 (0)