# Copyright (c) Microsoft Corporation. All rights reserved. # # This source code is subject to terms and conditions of the Apache License, Version 2.0. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### # COM Interop tests for IronPython from iptest.assert_util import skiptest skiptest("win32") from iptest.cominterop_util import * from System import DateTime, TimeSpan, Reflection, Int32, String from System.Runtime.InteropServices import COMException from clr import StrongBox com_type_name = "DlrComLibrary.OptionalParams" #------------------------------------------------------------------------------ # Create a COM object com_obj = getRCWFromProgID(com_type_name) #------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved. # # This source code is subject to terms and conditions of the Apache License, Version 2.0. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### # COM Interop tests for IronPython from iptest.assert_util import skiptest skiptest("win32", "silverlight") from iptest.cominterop_util import * from System import * from System.Runtime.InteropServices import COMException, DispatchWrapper from clr import StrongBox com_type_name = "DlrComLibrary.InOutParams" #------------------------------------------------------------------------------ # Create a COM object com_obj = getRCWFromProgID(com_type_name) #------------------------------------------------------------------------------ simple_primitives_data = [("mByte", Byte, 2, 4), ("mBstr", str, "a", "aa"), ("mDouble", float, 2.5, 4.5)]
# you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### """ Sanity tests for exceptions automatically generated by generate_exceptions.py (that cannot be hit under normal circumstances). """ from iptest.assert_util import run_test, AreEqual, skiptest, testpath skiptest("win32") import sys import clr clr.AddReference("IronPython") import IronPython.Runtime.Exceptions as IRE #----------------------------------------------------------------------------------- #--Helpers def gen_testcase(exc_name): def temp_func(): e0 = eval("IRE.%s()" % exc_name) e2 = eval("IRE.%s('msg', e0)" % exc_name) AreEqual(e0.Message, e2.InnerException.Message) AreEqual("msg", e2.Message)
# # This source code is subject to terms and conditions of the Apache License, Version 2.0. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### # ADO Database from iptest.assert_util import skiptest skiptest("win32", "silverlight", "cli64") from iptest.cominterop_util import * import System #------------------------------------------------------------------------------ #--GLOBALS #------------------------------------------------------------------------------ #--TESTS def test_cp18225(): com_obj_cmd = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Command")) com_obj_cmd.CommandTimeout = 50 AreEqual(com_obj_cmd.CommandTimeout, 50) com_obj_conn = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Connection"))
# Copyright (c) Microsoft Corporation. All rights reserved. # # This source code is subject to terms and conditions of the Microsoft Public License. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Microsoft Public License, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Microsoft Public License. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### # COM Interop tests for IronPython from iptest.assert_util import skiptest skiptest("win32", "silverlight") from iptest.cominterop_util import * from System import NullReferenceException from System.Runtime.InteropServices import COMException com_type_name = "DlrComLibrary.ReturnValues" #------------------------------------------------------------------------------ # Create a COM object com_obj = getRCWFromProgID(com_type_name) #------------------------------------------------------------------------------ #Test making calls to COM methods which return non-HRESULT values def test_nonHRESULT_retvals(): com_obj.mNoRetVal() #void
# # Copyright (c) Microsoft Corporation. All rights reserved. # # This source code is subject to terms and conditions of the Apache License, Version 2.0. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### from iptest.assert_util import skiptest skiptest("silverlight") from iptest.cominterop_util import * from System import * from clr import StrongBox ############################################################################### ##GLOBALS###################################################################### com_type_name = "DlrComLibrary.DispEvents" com_obj = getRCWFromProgID(com_type_name) N = 3 #number of events to send HANDLER_CALL_COUNT = 0 #number of events received ############################################################################### ##HELPERS######################################################################
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### # MSAgent COM Interop tests from iptest.assert_util import skiptest skiptest("win32", "silverlight", "cli64", "posix") from iptest.cominterop_util import * from clr import StrongBox from System.Runtime.InteropServices import DispatchWrapper if is_win7: import sys print("MSAgent is unavailable on Windows 7!") sys.exit(0) #------------------------------------------------------------------------------ #--GLOBALS com_obj = CreateAgentServer() #------------------------------------------------------------------------------ #--TESTS
# Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. # COM Interop tests for IronPython from iptest.assert_util import skiptest skiptest("win32", "cli64") from iptest.cominterop_util import * from System import * from System.Runtime.InteropServices import COMException, DispatchWrapper, UnknownWrapper, CurrencyWrapper from clr import StrongBox com_type_name = "DlrComLibrary.OutParams" #------------------------------------------------------------------------------ # Create a COM object com_obj = getRCWFromProgID(com_type_name) #------------------------------------------------------------------------------ #-------------------------------Helpers---------------------------------------- #------------------------------------------------------------------------------ def testhelper(function, type, values, equality_func=AreEqual): for i in xrange(len(values)): try: strongVar1 = StrongBox[type]() function(values[i], strongVar1) except Exception, e: print "FAILED trying to pass", values[i], "of type", type( values[i]), "to", function #.__name__
# Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. # Word Interop tests for IronPython from iptest.assert_util import skiptest skiptest("win32", "cli64", "posix") from iptest.cominterop_util import * from iptest.file_util import file_exists, delete_files import nt #------------------------------------------------------------------------------ #--SANITY CHECK if not IsWordInstalled(): from sys import exit print("Word is not installed. Cannot run this test!") exit(1) else: TryLoadWordInteropAssembly() from Microsoft.Office.Interop import Word #------------------------------------------------------------------------------ #--HELPERS def IsWordPIAInstalled(): from Microsoft.Win32 import Registry word_pia_registry = None wordapp_pia_registry = Registry.ClassesRoot.OpenSubKey( "CLSID\\{000209FF-0000-0000-C000-000000000046}\\InprocServer32") #worddoc_pia_registry = Registry.ClassesRoot.OpenSubKey("CLSID\\{00020906-0000-0000-C000-000000000046}\\InprocServer32") return wordapp_pia_registry != None
# Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. # ADO Database from iptest.assert_util import skiptest skiptest("win32", "cli64", "posix") from iptest.cominterop_util import * import System #------------------------------------------------------------------------------ #--GLOBALS #------------------------------------------------------------------------------ #--TESTS def test_cp18225(): com_obj_cmd = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Command")) com_obj_cmd.CommandTimeout = 50 AreEqual(com_obj_cmd.CommandTimeout, 50) com_obj_conn = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Connection")) com_obj_conn.CommandTimeout = 40 AreEqual(com_obj_conn.CommandTimeout, 40) #------------------------------------------------------------------------------ run_com_test(__name__, __file__)
# you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### ''' Ensures we can import from .NET 2.0 namespaces and types ''' #--IMPORTS--------------------------------------------------------------------- from iptest.assert_util import skiptest, is_cli, run_test, is_posix skiptest("win32", "silverlight") skiptest("netstandard") # references are different in netstandard import clr clr.AddReference("System.Configuration") clr.AddReference("System.Configuration.Install") clr.AddReference("System.Data") clr.AddReference("System.Data.OracleClient") if is_posix: clr.AddReference("System.Data.SqlClient") else: clr.AddReference("System.Data.SqlXml") clr.AddReference("System.Deployment") clr.AddReference("System.Design") clr.AddReference("System.DirectoryServices") clr.AddReference("System.DirectoryServices.Protocols")
# Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. # COM Interop tests for IronPython from iptest.assert_util import skiptest skiptest("win32", "cli64") from iptest.cominterop_util import * from System import * from System.Runtime.InteropServices import COMException, DispatchWrapper, UnknownWrapper, CurrencyWrapper from clr import StrongBox com_type_name = "DlrComLibrary.OutParams" #------------------------------------------------------------------------------ # Create a COM object com_obj = getRCWFromProgID(com_type_name) #------------------------------------------------------------------------------ #-------------------------------Helpers---------------------------------------- #------------------------------------------------------------------------------ def testhelper(function, type, values, equality_func=AreEqual): for i in xrange(len(values)): try: strongVar1 = StrongBox[type]() function(values[i], strongVar1) except Exception, e: print "FAILED trying to pass", values[i], "of type", type(values[i]) ,"to", function#.__name__ raise e