1
# You need RubyUnit and MS Excel and MSI to run this test script
8
class TestOLEMETHOD < RUNIT::TestCase
11
@excel_app = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
14
m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
15
assert_instance_of(WIN32OLE_METHOD, m)
16
m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
17
assert_instance_of(WIN32OLE_METHOD, m)
18
m = WIN32OLE_METHOD.new(@excel_app, 'workbookopen')
19
assert_instance_of(WIN32OLE_METHOD, m)
22
m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
23
assert_equal('Quit', m.name)
26
m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
27
assert_equal('Quit', "#{m}")
30
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
31
assert_equal('Range', m.return_type)
32
m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
33
assert_equal('BSTR', m.return_type)
36
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
37
assert_equal(WIN32OLE::VARIANT::VT_PTR, m.return_vtype)
38
m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
39
assert_equal(WIN32OLE::VARIANT::VT_BSTR, m.return_vtype)
41
def test_return_type_detail
42
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
43
assert_equal(['PTR', 'USERDEFINED', 'Range'], m.return_type_detail)
44
m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
45
assert_equal(['BSTR'], m.return_type_detail)
49
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
50
assert_equal('PROPERTYGET', m.invoke_kind)
53
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
55
m = WIN32OLE_METHOD.new(@excel_app, 'AddRef')
59
m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
61
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
64
def test_event_interface
65
m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
66
assert_equal('AppEvents', m.event_interface)
67
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
68
assert_nil(m.event_interface)
71
domdoc = WIN32OLE_TYPE.new(MS_XML_TYPELIB, 'DOMDocument')
72
m = WIN32OLE_METHOD.new(domdoc, 'abort')
73
assert_equal('abort an asynchronous download', m.helpstring)
76
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
77
assert_match(/VBAXL.*\.(HLP|CHM)$/i, m.helpfile)
80
m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
81
assert(m.helpcontext > 0)
84
m = WIN32OLE_METHOD.new(@excel_app, 'QueryInterface')
85
assert_equal(0, m.offset_vtbl)
88
tobj = WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation', 'FolderItem2')
89
method = WIN32OLE_METHOD.new(tobj, 'InvokeVerb')
90
assert_equal(1610743824, method.dispid)