1# This is test script to check that WIN32OLE should convert nil to VT_EMPTY in second try.
2# [ruby-talk:137054]
3begin
4  require 'win32ole'
5rescue LoadError
6end
7require 'test/unit'
8
9if defined?(WIN32OLE)
10  class TestNIL2VT_EMPTY < Test::Unit::TestCase
11    def setup
12      fs = WIN32OLE.new('Scripting.FileSystemObject')
13      @path = fs.GetFolder(".").path
14    end
15    def test_openSchema
16      con = nil
17      begin
18        con = WIN32OLE.new('ADODB.Connection')
19        con.connectionString = "Provider=MSDASQL;Extended Properties="
20        con.connectionString +="\"DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=#{@path}\""
21        con.open
22      rescue
23        con = nil
24      end
25      if con
26        rs = con.openSchema(4, [nil,nil,"DUMMY", "TABLE"])
27        assert(rs)
28        assert_equal("_Recordset", rs.ole_type.name)
29
30        rs = con.openSchema(4, [WIN32OLE_VARIANT::Empty, WIN32OLE_VARIANT::Empty, "DUMMY", "TABLE"])
31        assert(rs)
32        assert_equal("_Recordset", rs.ole_type.name)
33      end
34    end
35  end
36end
37