|
| 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 | +} |