Class: TestOLETYPE

Inherits:
RUNIT::TestCase
  • Object
show all
Includes:
OLESERVER
Defined in:
tests/testOLETYPE.rb

Constant Summary

Constants included from OLESERVER

OLESERVER::MS_EXCEL_TYPELIB, OLESERVER::MS_XML_TYPELIB

Instance Method Summary collapse

Instance Method Details

#test_class_to_sObject



35
36
37
38
39
40
41
# File 'tests/testOLETYPE.rb', line 35

def test_class_to_s
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  class_names = classes.collect{|c|
    "#{c}"
  }
  assert(class_names.include?('Application'))
end

#test_helpcontextObject



87
88
89
90
91
# File 'tests/testOLETYPE.rb', line 87

def test_helpcontext
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  worksheet = classes.find {|c| c.name == 'Worksheet'}
  assert_equal(131088, worksheet.helpcontext)
end

#test_helpfileObject



82
83
84
85
86
# File 'tests/testOLETYPE.rb', line 82

def test_helpfile
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  worksheet = classes.find {|c| c.name == 'Worksheet'}
  assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile)
end

#test_helpstringObject



67
68
69
70
71
# File 'tests/testOLETYPE.rb', line 67

def test_helpstring
  classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
  domdoc = classes.find {|c| c.name == 'DOMDocument'}
  assert_equal('W3C-DOM XML Document', domdoc.helpstring)
end

#test_nameObject



27
28
29
30
31
32
33
# File 'tests/testOLETYPE.rb', line 27

def test_name
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  class_names = classes.collect{|c|
    c.name
  }
  assert(class_names.include?('Application'))
end

#test_ole_methodsObject



77
78
79
80
81
# File 'tests/testOLETYPE.rb', line 77

def test_ole_methods
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  worksheet = classes.find {|c| c.name == 'Worksheet'}
  assert(worksheet.ole_methods.size > 0)
end

#test_ole_typeObject



43
44
45
46
47
48
49
# File 'tests/testOLETYPE.rb', line 43

def test_ole_type
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  app = classes.find {|c| c.name == 'Application'}
  assert_equal('Class', app.ole_type)
  app = classes.find {|c| c.name == '_Application'}
  assert_equal('Dispatch', app.ole_type)
end

#test_s_newObject



10
11
12
13
# File 'tests/testOLETYPE.rb', line 10

def test_s_new
  type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
  assert_instance_of(WIN32OLE_TYPE, type)
end

#test_s_ole_classesObject



14
15
16
17
# File 'tests/testOLETYPE.rb', line 14

def test_s_ole_classes
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  assert(classes.size > 0)
end

#test_s_progidsObject



23
24
25
26
# File 'tests/testOLETYPE.rb', line 23

def test_s_progids
  progids = WIN32OLE_TYPE.progids
  assert(progids.include?('Excel.Application'))
end

#test_s_typelibsObject



18
19
20
21
22
# File 'tests/testOLETYPE.rb', line 18

def test_s_typelibs
  libs = WIN32OLE_TYPE.typelibs
  assert(libs.include?(MS_EXCEL_TYPELIB))
  assert(libs.include?(MS_XML_TYPELIB))
end

#test_src_typeObject



62
63
64
65
66
# File 'tests/testOLETYPE.rb', line 62

def test_src_type
  classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
  domnode = classes.find {|c| c.name == 'DOMNodeType'}
  assert_equal('tagDOMNodeType', domnode.src_type)
end

#test_to_sObject



92
93
94
95
# File 'tests/testOLETYPE.rb', line 92

def test_to_s
  type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
  assert_equal("Application", "#{type}");
end

#test_typekindObject



50
51
52
53
54
# File 'tests/testOLETYPE.rb', line 50

def test_typekind
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  app = classes.find {|c| c.name == 'Application'}
  assert_equal(5, app.typekind)
end

#test_variablesObject



72
73
74
75
76
# File 'tests/testOLETYPE.rb', line 72

def test_variables
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  xlchart = classes.find {|c| c.name == 'XlChartType'}
  assert(xlchart.variables.size > 0)
end

#test_visibleObject



55
56
57
58
59
60
61
# File 'tests/testOLETYPE.rb', line 55

def test_visible
  classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
  app = classes.find {|c| c.name == 'Application'}
  assert(app.visible?)
  app = classes.find {|c| c.name == 'IAppEvents'}
  assert(!app.visible?)
end