mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
7e190d7568
add WIN32OLE_VARIABLE#to_s method. add WIN32OLE_METHOD#to_s method. add WIN32OLE_PARAM#to_s method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
74 lines
2.8 KiB
Ruby
74 lines
2.8 KiB
Ruby
# You need RubyUnit and MS Excel and MSI to run this test script
|
|
|
|
require 'rubyunit'
|
|
|
|
require 'win32ole'
|
|
require 'oleserver'
|
|
|
|
class TestOLEPARAM < RUNIT::TestCase
|
|
include OLESERVER
|
|
def test_name
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
sh = classes.find {|c| c.name == 'Worksheet'}
|
|
saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
|
|
param_names = saveas.params.collect{|p| p.name}
|
|
assert(param_names.size > 0)
|
|
assert(param_names.include?('Filename'))
|
|
end
|
|
def test_to_s
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
sh = classes.find {|c| c.name == 'Worksheet'}
|
|
saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
|
|
param_names = saveas.params.collect{|p| "#{p}"}
|
|
assert(param_names.include?('Filename'))
|
|
end
|
|
def test_ole_type
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert_equal('BSTR', f.params[0].ole_type)
|
|
methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert_equal('XlSaveAsAccessMode', f.params[6].ole_type)
|
|
end
|
|
def test_ole_type_detail
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert_equal(['BSTR'], f.params[0].ole_type_detail)
|
|
methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert_equal(['USERDEFINED', 'XlSaveAsAccessMode'], f.params[6].ole_type_detail)
|
|
end
|
|
def test_input
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert(f.params[0].input?)
|
|
end
|
|
|
|
def test_output
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert(!f.params[0].output?)
|
|
end
|
|
def test_optional
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert(!f.params[0].optional?)
|
|
methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert(f.params[0].optional?)
|
|
end
|
|
def test_ole_type_detail
|
|
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
|
methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert_equal(nil, f.params[0].default)
|
|
methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
|
|
f = methods.find {|m| m.name == 'SaveAs'}
|
|
assert_equal(1, f.params[6].default)
|
|
end
|
|
end
|