Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87ddcc0

Browse files
benoithudsonBadSingleton
benoithudson
authored andcommitted
Added test for member function rename.
1 parent 98b60ec commit 87ddcc0

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/domain_tests/TestRunner.cs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,50 @@ import sys
9595
else:
9696
raise AssertionError('Failed to throw exception')
9797
",
98-
}
98+
},
99+
new TestCase {
100+
Name = "member_rename",
101+
DotNetBefore = @"
102+
namespace TestNamespace {
103+
[System.Serializable]
104+
public class Cls { public int Before() { return 5; } }
105+
}",
106+
DotNetAfter = @"
107+
namespace TestNamespace {
108+
[System.Serializable]
109+
public class Cls { public int After() { return 10; } }
110+
}",
111+
PythonCode = @"
112+
import clr
113+
clr.AddReference('DomainTests')
114+
import TestNamespace
115+
def before():
116+
import sys
117+
sys.my_cls = TestNamespace.Cls
118+
sys.my_fn = TestNamespace.Cls.Before
119+
def after():
120+
import sys
121+
122+
# We should have reloaded the class so we can access the new function.
123+
assert 10 == sys.my_cls.After()
124+
125+
try:
126+
# We should have reloaded the class so we can't access the old function.
127+
sys.my_cls.Before()
128+
except AttributeError:
129+
print('Caught expected AttributeError')
130+
else:
131+
raise AssertionError('Failed to throw exception: expected AttributeError accessing class member that no longer exists')
132+
133+
try:
134+
# We should have failed to reload the function which no longer exists.
135+
sys.my_fn()
136+
except TypeError:
137+
print('Caught expected TypeError')
138+
else:
139+
raise AssertionError('Failed to throw exception: expected TypeError accessing .NET field that no longer exists')
140+
",
141+
},
99142
};
100143

101144
/// <summary>

src/domain_tests/test_domain_reload.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ def _run_test(testname):
1414

1515
def test_rename_class():
1616
_run_test('class_rename')
17+
18+
def test_rename_class_member_function():
19+
_run_test('member_rename')

0 commit comments

Comments
 (0)