
import clr
import sys
import os

def test():
    dll_dir = os.path.join(os.getcwd(), "libs")
    sys.path.append(dll_dir)
    clr.AddReference("rapiplus")
    import com.omnesys.rapi as rapi
    
    print("--- Test 1: Instantiating REngine with None callbacks ---")
    try:
        params = rapi.REngineParams()
        params.AdmCallbacks = None
        engine = rapi.REngine(params)
        print("REngine instantiation success with None!")
    except Exception as e:
        print(f"REngine instantiation failed: {e}")

    print("\n--- Test 2: Instantiating simple RCallbacks subclass (Concrete) ---")
    class MyR(rapi.RCallbacks):
        pass
    try:
        r = MyR()
        print("MyR instantiation success!")
    except Exception as e:
        print(f"MyR instantiation failed: {e}")

    print("\n--- Test 3: Instantiating simple AdmCallbacks subclass (Abstract) ---")
    class MyAdm(rapi.AdmCallbacks):
        def Alert(self, oInfo):
            pass
    try:
        a = MyAdm()
        print("MyAdm instantiation success!")
    except Exception as e:
        print(f"MyAdm instantiation failed: {e}")

    print("\n--- Test 4: AdmCallbacks inheritance WITHOUT __init__ ---")
    class MyAdm2(rapi.AdmCallbacks):
        def Alert(self, oInfo): pass
    try:
        a2 = MyAdm2()
        print("MyAdm2 instantiation success!")
    except Exception as e:
        print(f"MyAdm2 instantiation failed: {e}")

if __name__ == "__main__":
    test()
