Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd06d10

Browse files
committed
Add test for interface derived classes
1 parentbd94e49 commitcd06d10

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
usingNUnit.Framework;
2+
usingPython.Runtime;
3+
4+
namespacePython.EmbeddingTest
5+
{
6+
publicclassTestInterfaceClasses
7+
{
8+
publicstringtestCode=@"
9+
from clr import AddReference
10+
AddReference(""System"")
11+
AddReference(""Python.EmbeddingTest"")
12+
from Python.EmbeddingTest import *
13+
14+
testModule = TestInterfaceClasses.GetInstance()
15+
print(testModule.Child.ChildBool)
16+
17+
";
18+
19+
[OneTimeSetUp]
20+
publicvoidSetUp()
21+
{
22+
PythonEngine.Initialize();
23+
}
24+
25+
[OneTimeTearDown]
26+
publicvoidDispose()
27+
{
28+
PythonEngine.Shutdown();
29+
}
30+
31+
[Test]
32+
publicvoidTestInterfaceDerivedClassMembers()
33+
{
34+
// This test gets an instance of the CSharpTestModule in Python
35+
// and then attempts to access it's member "Child"'s bool that is
36+
// not defined in the interface.
37+
PythonEngine.Exec(testCode);
38+
}
39+
40+
publicinterfaceIInterface
41+
{
42+
boolInterfaceBool{get;set;}
43+
}
44+
45+
publicclassParent:IInterface
46+
{
47+
publicboolInterfaceBool{get;set;}
48+
publicboolParentBool{get;set;}
49+
}
50+
51+
publicclassChild:Parent
52+
{
53+
publicboolChildBool{get;set;}
54+
}
55+
56+
publicclassCSharpTestModule
57+
{
58+
publicIInterfaceChild;
59+
60+
publicCSharpTestModule()
61+
{
62+
Child=newChild
63+
{
64+
ChildBool=true,
65+
ParentBool=true,
66+
InterfaceBool=true
67+
};
68+
}
69+
}
70+
71+
publicstaticCSharpTestModuleGetInstance()
72+
{
73+
returnnewCSharpTestModule();
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp