* 2022-01-18 [ci skip]
[ruby-80x24.org.git] / test / win32ole / test_win32ole_variable.rb
blob8af3f987a8fc7f34b6a57b3ea2af15860f4127a8
1 # frozen_string_literal: false
2 begin
3   require 'win32ole'
4 rescue LoadError
5 end
6 require "test/unit"
8 if defined?(WIN32OLE_VARIABLE)
9   class TestWIN32OLE_VARIABLE < Test::Unit::TestCase
11     def setup
12       ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
13       @var1 = ole_type.variables.find {|v| v.name == 'ssfDESKTOP'}
15       variables = WIN32OLE_TYPE.new("Microsoft Windows Installer Object Library", "Installer").variables
16       @var2 = variables.find {|v| v.name == 'UILevel'}
17     end
19     def test_initialize
20       assert_raise(TypeError) {WIN32OLE_VARIABLE.new}
21     end
23     def test_name
24       assert_equal('ssfDESKTOP', @var1.name)
25     end
27     def test_ole_type
28       assert_equal('INT', @var1.ole_type)
29       assert_equal('MsiUILevel', @var2.ole_type)
30     end
32     def test_ole_type_detail
33       assert_equal(['INT'], @var1.ole_type_detail)
34       assert_equal(['USERDEFINED', 'MsiUILevel'], @var2.ole_type_detail)
35     end
37     def test_ole_type_value
38       assert_equal(0, @var1.value)
39       assert_equal(nil, @var2.value)
40     end
42     def test_ole_type_visible?
43       assert(@var1.visible?)
44     end
46     def test_ole_type_variable_kind
47       assert_equal("CONSTANT", @var1.variable_kind)
48       assert_equal("DISPATCH", @var2.variable_kind)
49     end
51     def test_ole_type_varkind
52       assert_equal(2, @var1.varkind)
53       assert_equal(3, @var2.varkind)
54     end
56     def test_to_s
57       assert_equal(@var1.name, @var1.to_s)
58     end
60     def test_inspect
61       assert_equal("#<WIN32OLE_VARIABLE:ssfDESKTOP=0>",  @var1.inspect)
62       assert_equal("#<WIN32OLE_VARIABLE:UILevel=nil>", @var2.inspect)
63     end
65   end
66 end