1 # frozen_string_literal: false
8 if defined?(WIN32OLE_PARAM)
9 class TestWIN32OLE_PARAM < Test::Unit::TestCase
12 ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellLinkObject")
13 m_geticonlocation = WIN32OLE_METHOD.new(ole_type, "GetIconLocation")
14 @param_pbs = m_geticonlocation.params[0]
16 ole_type = WIN32OLE_TYPE.new("Microsoft HTML Object Library", "FontNames")
17 m_count = WIN32OLE_METHOD.new(ole_type, "Count")
18 @param_p = m_count.params[0]
20 ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject")
21 m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile")
22 @param_source = m_copyfile.params[0]
23 @param_overwritefiles = m_copyfile.params[2]
25 ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Dictionary")
26 m_add = WIN32OLE_METHOD.new(ole_type, "Add")
27 @param_key = m_add.params[0]
31 assert_raise(ArgumentError) {
32 WIN32OLE_PARAM.new("hoge")
34 ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject")
35 m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile")
36 assert_raise(IndexError) {
37 WIN32OLE_PARAM.new(m_copyfile, 4);
39 assert_raise(IndexError) {
40 WIN32OLE_PARAM.new(m_copyfile, 0);
42 param = WIN32OLE_PARAM.new(m_copyfile, 3)
43 assert_equal("OverWriteFiles", param.name)
44 assert_equal(WIN32OLE_PARAM, param.class)
45 assert_equal(true, param.default)
46 assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", param.inspect)
50 assert_equal('Source', @param_source.name)
51 assert_equal('Key', @param_key.name)
55 assert_equal('BSTR', @param_source.ole_type)
56 assert_equal('VARIANT', @param_key.ole_type)
59 def test_ole_type_detail
60 assert_equal(['BSTR'], @param_source.ole_type_detail)
61 assert_equal(['PTR', 'VARIANT'], @param_key.ole_type_detail)
65 assert_equal(true, @param_source.input?)
66 assert_equal(false, @param_pbs.input?)
70 assert_equal(false, @param_source.output?)
71 assert_equal(true, @param_pbs.output?)
75 assert_equal(false, @param_source.optional?)
76 assert_equal(true, @param_overwritefiles.optional?)
80 assert_equal(false, @param_source.retval?)
81 assert_equal(true, @param_p.retval?)
85 assert_equal(nil, @param_source.default)
86 assert_equal(true, @param_overwritefiles.default)
90 assert_equal(@param_source.name, @param_source.to_s)
94 assert_equal("#<WIN32OLE_PARAM:Source>", @param_source.inspect)
95 assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", @param_overwritefiles.inspect)