DEFINITIONS
This source file includes following functions.
1 # You need RubyUnit and MS Excel and MSI to run this test script
2
3 require 'rubyunit'
4
5 require 'win32ole'
6 require 'oleserver'
7
8 class TestOLEPARAM < RUNIT::TestCase
9 include OLESERVER
10 def test_name
11 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
12 sh = classes.find {|c| c.name == 'Worksheet'}
13 saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
14 param_names = saveas.params.collect{|p| p.name}
15 assert(param_names.size > 0)
16 assert(param_names.include?('Filename'))
17 end
18 def test_ole_type
19 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
20 methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
21 f = methods.find {|m| m.name == 'SaveAs'}
22 assert_equal('BSTR', f.params[0].ole_type)
23 methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
24 f = methods.find {|m| m.name == 'SaveAs'}
25 assert_equal('XlSaveAsAccessMode', f.params[6].ole_type)
26 end
27 def test_ole_type_detail
28 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
29 methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
30 f = methods.find {|m| m.name == 'SaveAs'}
31 assert_equal(['BSTR'], f.params[0].ole_type_detail)
32 methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
33 f = methods.find {|m| m.name == 'SaveAs'}
34 assert_equal(['USERDEFINED', 'XlSaveAsAccessMode'], f.params[6].ole_type_detail)
35 end
36 def test_input
37 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
38 methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
39 f = methods.find {|m| m.name == 'SaveAs'}
40 assert(f.params[0].input?)
41 end
42
43 def test_output
44 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
45 methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
46 f = methods.find {|m| m.name == 'SaveAs'}
47 assert(!f.params[0].output?)
48 end
49 def test_optional
50 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
51 methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
52 f = methods.find {|m| m.name == 'SaveAs'}
53 assert(!f.params[0].optional?)
54 methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
55 f = methods.find {|m| m.name == 'SaveAs'}
56 assert(f.params[0].optional?)
57 end
58 def test_ole_type_detail
59 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
60 methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
61 f = methods.find {|m| m.name == 'SaveAs'}
62 assert_equal(nil, f.params[0].default)
63 methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
64 f = methods.find {|m| m.name == 'SaveAs'}
65 assert_equal(1, f.params[6].default)
66 end
67 end