def test_sanity(): for test_data in simple_primitives_data: testFunctionName = test_data[0] testType = test_data[1] testValue = test_data[2] testFunction = getattr(com_obj, testFunctionName) strongBox = StrongBox[testType]() testFunction(testValue, strongBox) AreEqual(strongBox.Value, testValue) testFunction(1, strongBox) AreEqual(strongBox.Value, 1) testFunction(0, strongBox) AreEqual(strongBox.Value, 0) AreEqual(callMethodWithStrongBox(com_obj.mBstr, "Hello", str), "Hello") #Interface Types strongVar = StrongBox[object](DispatchWrapper(None)) com_obj.mIDispatch(com_obj, strongVar) AreEqual(strongVar.Value.WrappedObject, com_obj) strongVar = StrongBox[object](UnknownWrapper(None)) com_obj.mIUnknown(com_obj, strongVar) AreEqual(strongVar.Value.WrappedObject, com_obj) #Complex Types strongVar = StrongBox[object](CurrencyWrapper(444)) com_obj.mCy(CurrencyWrapper(123), strongVar) AreEqual(strongVar.Value.WrappedObject, 123) now = DateTime.Now AreEqual(str(callMethodWithStrongBox(com_obj.mDate, now, DateTime)), str(now)) AreEqual(callMethodWithStrongBox(com_obj.mVariant, Single(2.0), object), 2.0)
def test_merlin(): from time import sleep Assert('Equals' in dir(com_obj)) charID = StrongBox[int](0) reqID = StrongBox[int](0) com_obj.Load('Merlin.acs', charID, reqID) cid = charID.Value character = StrongBox[object](DispatchWrapper(None)) com_obj.GetCharacter(cid, character) c = character.Value.WrappedObject sleep(1) if is_snap or testpath.basePyDir.lower() == 'src': c.Show(0, reqID) sleep(1) visible = StrongBox[int](0) while visible.Value == 0: c.GetVisible(visible) sleep(1) c.Think('IronPython...', reqID) c.Play('Read', reqID) c.GestureAt(True, False, reqID) c.GestureAt(100, 200, reqID) AssertError( OverflowError, c.GestureAt, 65537.34, 32 ) # It should be an error to convert a float to Int16 since it will not fit c.Speak('hello world', None, reqID) c.StopAll(0) c.Hide(0, reqID) sleep(1) com_obj.Unload(cid) delete_files("AgentServerObjects.dll")