Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

819 lines
27 KiB

  1. <!--
  2. ******************************************************************
  3. '
  4. ' addvalues.wsf
  5. '
  6. ' Purpose: test SWbemPropertyEx::AddValues
  7. '
  8. ' Parameters: none
  9. '
  10. ' Returns: 0 - success
  11. ' 1 - failure
  12. '
  13. '*****************************************************************
  14. -->
  15. <job id="WMI AddValues Test">
  16. <reference object="WbemScripting.SWbemLocator" version="1.2"/>
  17. <script language="VBScript">
  18. on error resume next
  19. set scriptHelper = CreateObject("WMIScriptHelper.WSC")
  20. scriptHelper.logFile = "c:\temp\addvalues.txt"
  21. scriptHelper.loggingLevel = 3
  22. scriptHelper.testName = "WMI AddValues"
  23. scriptHelper.testStart
  24. dim ns
  25. dim newClass
  26. ' Connect to the namespace
  27. set ns = GetObject("winmgmts:root\default")
  28. if err <> 0 then
  29. scriptHelper.writeErrorToLog err, "Failed to connect to root\default"
  30. else
  31. scriptHelper.writeToLog "Successful connection to root\default", 2
  32. end if
  33. 'Make a new class
  34. set newClass = ns.Get
  35. if err <> 0 then
  36. scriptHelper.writeErrorToLog err, "Failed to get empty class"
  37. else
  38. scriptHelper.writeToLog "Successful retrieval of empty class", 2
  39. end if
  40. newClass.Path_.Class = "ADDVALUES000TEST"
  41. ' Add a non-array property (uint32)
  42. set p0 = newClass.Properties_.Add ("p0", 19)
  43. p0 = 251
  44. ' Add some array properties, one for each type
  45. set p = newClass.Properties_.Add ("pSint8", wbemCimtypeSint8, true)
  46. p.Value = Array (-1, 0, 1, 2)
  47. newClass.Properties_.Add "pUint8", wbemCimtypeUint8, true
  48. newClass.Properties_.Add "pSint16", wbemCimtypeSint16, true
  49. newClass.Properties_.Add "pUint16", wbemCimtypeUint16, true
  50. newClass.Properties_.Add "pSint32", wbemCimtypeSint32, true
  51. newClass.Properties_.Add "pUint32", wbemCimtypeUint32, true
  52. newClass.Properties_.Add "pSint64", wbemCimtypeSint64, true
  53. newClass.Properties_.Add "pUint64", wbemCimtypeUint64, true
  54. newClass.Properties_.Add "pReal32", wbemCimtypeReal32, true
  55. newClass.Properties_.Add "pReal64", wbemCimtypeReal64, true
  56. newClass.Properties_.Add "pBoolean", wbemCimtypeBoolean, true
  57. set p = newClass.Properties_.Add ("pString", wbemCimtypeString, true)
  58. p.Value = Array ("I", "have", "but")
  59. newClass.Properties_.Add "pDatetime", wbemCimtypeDatetime, true
  60. newClass.Properties_.Add "pReference", wbemCimtypeReference, true
  61. newClass.Properties_.Add "pChar16", wbemCimtypeChar16, true
  62. newClass.Properties_.Add "pObject", wbemCimtypeObject, true
  63. if err <> 0 then
  64. scriptHelper.writeErrorToLog err, "Failed to define class"
  65. else
  66. scriptHelper.writeToLog "Successful definition of class", 2
  67. end if
  68. ' Save the class
  69. newClass.Put_
  70. if err <> 0 then
  71. scriptHelper.writeErrorToLog err, "Failed to save class"
  72. else
  73. scriptHelper.writeToLog "Successful save of class", 2
  74. end if
  75. ' Get it back
  76. set newClass = ns.Get ("ADDVALUES000TEST")
  77. if err <> 0 then
  78. scriptHelper.writeErrorToLog err, "Failed to get class"
  79. else
  80. scriptHelper.writeToLog "Successful get of class", 2
  81. end if
  82. ' now test each property type
  83. TestUint8
  84. TestSint8
  85. TestUint16
  86. TestSint16
  87. TestUint32
  88. TestSint32
  89. TestUint64
  90. TestSint64
  91. TestReal32
  92. TestReal64
  93. TestBoolean
  94. TestString
  95. TestDatetime
  96. TestReference
  97. TestChar16
  98. TestObject
  99. ' Save the class
  100. newClass.Put_
  101. if err <> 0 then
  102. scriptHelper.writeErrorToLog err, "Failed to save class"
  103. else
  104. scriptHelper.writeToLog "Successful save of class", 2
  105. end if
  106. ' Clean up
  107. newClass.Delete_
  108. if err <> 0 then
  109. scriptHelper.writeErrorToLog err, "Failed to delete class"
  110. else
  111. scriptHelper.writeToLog "Successful delete of class", 2
  112. end if
  113. scriptHelper.testComplete
  114. if scriptHelper.statusOK then
  115. WScript.Echo "PASS"
  116. WScript.Quit 0
  117. else
  118. WScript.Echo "FAIL"
  119. WScript.Quit 1
  120. end if
  121. '****************************************************************
  122. '*
  123. '* TestUint8
  124. '* =========
  125. '*
  126. '* Test AddValues for uint8 arrays
  127. '*
  128. '****************************************************************
  129. Sub TestUint8
  130. on error resume next
  131. ' Try an add of a simple value
  132. set pUint8 = newClass.Properties_("pUint8")
  133. pUint8.AddValues 1
  134. scriptHelper.scriptHelper.DisplayValue newClass, newClass, "pUint8"
  135. scriptHelper.VerifyValue pUint8.Value, Array (1)
  136. ' Try an add of a simple value
  137. pUint8.AddValues 2
  138. scriptHelper.scriptHelper.DisplayValue newClass, newClass, "pUint8"
  139. scriptHelper.VerifyValue pUint8.Value, Array (1,2)
  140. ' Try an add of a complex value
  141. pUint8.AddValues Array (3, 4, 5)
  142. scriptHelper.DisplayValue newClass, "pUint8"
  143. scriptHelper.VerifyValue pUint8.Value, Array (1, 2, 3, 4, 5)
  144. ' Try an insert of a simple value
  145. pUint8.AddValues 0, wbemAddValuesInsert
  146. scriptHelper.DisplayValue newClass, "pUint8"
  147. scriptHelper.scriptHelper.VerifyValue pUint8.Value, Array (0, 1, 2, 3, 4, 5)
  148. ' Try an insert of a complex value
  149. pUint8.AddValues Array (12, 13, 14), wbemAddValuesInsert
  150. scriptHelper.DisplayValue newClass, "pUint8"
  151. scriptHelper.VerifyValue pUint8.Value, Array (12, 13, 14, 0, 1, 2, 3, 4, 5)
  152. ' Try an insert of a simple value
  153. pUint8.AddValues 100, wbemAddValuesInsert, -1
  154. scriptHelper.DisplayValue newClass, "pUint8"
  155. scriptHelper.VerifyValue pUint8.Value, Array (12, 13, 14, 0, 1, 2, 3, 4, 5, 100)
  156. ' Try an insert of a simple value
  157. pUint8.AddValues 101, wbemAddValuesInsert, 10
  158. scriptHelper.DisplayValue newClass, "pUint8"
  159. scriptHelper.VerifyValue pUint8.Value, Array (12, 13, 14, 0, 1, 2, 3, 4, 5, 100, 101)
  160. ' Try an insert of a complex value
  161. pUint8.AddValues Array (112, 113, 114), wbemAddValuesInsert, 3
  162. scriptHelper.DisplayValue newClass, "pUint8"
  163. scriptHelper.VerifyValue pUint8.Value, Array (12, 13, 14, 112, 113, 114, 0, 1, 2, 3, 4, 5, 100, 101)
  164. ' Try an insert of a complex value
  165. pUint8.AddValues Array (32, 33, 34), wbemAddValuesInsert, -1
  166. scriptHelper.DisplayValue newClass, "pUint8"
  167. scriptHelper.VerifyValue pUint8.Value, Array (12, 13, 14, 112, 113, 114, 0, 1, 2, 3, 4, 5, 100, 101, 32, 33, 34)
  168. End Sub
  169. '****************************************************************
  170. '*
  171. '* TestSint8
  172. '* =========
  173. '*
  174. '* Test AddValues for sint8 arrays
  175. '*
  176. '****************************************************************
  177. Sub TestSint8
  178. on error resume next
  179. ' Try an add of a simple value
  180. set pSint8 = newClass.Properties_("pSint8")
  181. pSint8.AddValues 3
  182. scriptHelper.DisplayValue newClass, "pSint8"
  183. scriptHelper.VerifyValue pSint8.Value, Array (-1, 0, 1, 2, 3)
  184. ' Try an add of a simple value
  185. pSint8.AddValues 4
  186. scriptHelper.DisplayValue newClass, "pSint8"
  187. scriptHelper.VerifyValue pSint8.Value, Array (-1, 0, 1, 2, 3, 4)
  188. ' Try an add of a complex value
  189. pSint8.AddValues Array (5, 6, 7, 8)
  190. scriptHelper.DisplayValue newClass, "pSint8"
  191. scriptHelper.VerifyValue pSint8.Value, Array (-1, 0, 1, 2, 3, 4, 5, 6, 7, 8)
  192. ' Try an insert of a simple value
  193. pSint8.AddValues 101, wbemAddValuesInsert, 10
  194. scriptHelper.DisplayValue newClass, "pSint8"
  195. scriptHelper.VerifyValue pSint8.Value, Array (-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 101)
  196. ' Try an insert of a complex value
  197. pSint8.AddValues Array (-112, 113, -114), wbemAddValuesInsert, 3
  198. scriptHelper.DisplayValue newClass, "pSint8"
  199. scriptHelper.VerifyValue pSint8.Value, Array (-1, 0, 1, -112, 113, -114, 2, 3, 4, 5, 6, 7, 8, 101)
  200. End Sub
  201. '****************************************************************
  202. '*
  203. '* TestString
  204. '* ============
  205. '*
  206. '* Test AddValues for string arrays
  207. '*
  208. '****************************************************************
  209. Sub TestString
  210. on error resume next
  211. ' Try an add of a simple value
  212. set pString = newClass.Properties_("pString")
  213. pString.AddValues "an"
  214. scriptHelper.DisplayValue newClass, "pString"
  215. scriptHelper.VerifyValue pString.Value, Array ("I", "have", "but", "an")
  216. ' Try an add of a simple value
  217. pString.AddValues "hour"
  218. scriptHelper.DisplayValue newClass, "pString"
  219. scriptHelper.VerifyValue pString.Value, Array ("I", "have", "but", "an", "hour")
  220. ' Try an add of a complex value
  221. pString.AddValues Array ("Obey", "the", "time")
  222. scriptHelper.DisplayValue newClass, "pString"
  223. scriptHelper.VerifyValue pString.Value, Array ("I", "have", "but", "an", "hour", "Obey", "the", "time")
  224. ' Try an insert of a simple value
  225. pString.AddValues "Bill", wbemAddValuesInsert, 5
  226. scriptHelper.DisplayValue newClass, "pString"
  227. scriptHelper.VerifyValue pString.Value, Array ("I", "have", "but", "an", "hour", "Bill", "Obey", "the", "time")
  228. ' Try an insert of a complex value
  229. pString.AddValues Array ("the", "Shake"), wbemAddValuesInsert, 6
  230. scriptHelper.DisplayValue newClass, "pString"
  231. scriptHelper.VerifyValue pString.Value, Array ("I", "have", "but", "an", "hour", "Bill", "the", "Shake", "Obey", "the", "time")
  232. End Sub
  233. '****************************************************************
  234. '*
  235. '* TestUint16
  236. '* ==========
  237. '*
  238. '* Test AddValues for uint16 arrays
  239. '*
  240. '****************************************************************
  241. Sub TestUint16
  242. on error resume next
  243. ' Try an add of a simple value
  244. set pUint16 = newClass.Properties_("pUint16")
  245. pUint16.AddValues 0
  246. scriptHelper.DisplayValue newClass, "pUint16"
  247. scriptHelper.VerifyValue pUint16.Value, Array (0)
  248. ' Try an add of a simple value
  249. pUint16.AddValues 255
  250. scriptHelper.DisplayValue newClass, "pUint16"
  251. scriptHelper.VerifyValue pUint16.Value, Array (0,255)
  252. ' Try an add of a complex value
  253. pUint16.AddValues Array (256, 65534)
  254. scriptHelper.DisplayValue newClass, "pUint16"
  255. scriptHelper.VerifyValue pUint16.Value, Array (0, 255, 256, 65534)
  256. ' Try an insert of a simple value
  257. pUint16.AddValues 123, wbemAddValuesInsert, 1
  258. scriptHelper.DisplayValue newClass, "pUint16"
  259. scriptHelper.VerifyValue pUint16.Value, Array (0, 123, 255, 256, 65534)
  260. ' Try an insert of a complex value
  261. pUint16.AddValues Array (10, 12), wbemAddValuesInsert, 4
  262. scriptHelper.DisplayValue newClass, "pUint16"
  263. scriptHelper.VerifyValue pUint16.Value, Array (0, 123, 255, 256, 10, 12, 65534)
  264. End Sub
  265. '****************************************************************
  266. '*
  267. '* TestSint16
  268. '* ==========
  269. '*
  270. '* Test AddValues for sint16 arrays
  271. '*
  272. '****************************************************************
  273. Sub TestSint16
  274. on error resume next
  275. ' Try an add of a simple value
  276. set pSint16 = newClass.Properties_("pSint16")
  277. pSint16.AddValues -254
  278. scriptHelper.DisplayValue newClass, "pSint16"
  279. scriptHelper.VerifyValue pSint16.Value, Array (-254)
  280. ' Try an add of a simple value
  281. pSint16.AddValues -1
  282. scriptHelper.DisplayValue newClass, "pSint16"
  283. scriptHelper.VerifyValue pSint16.Value, Array (-254, -1)
  284. ' Try an add of a complex value
  285. pSint16.AddValues Array (0, 1, 255)
  286. scriptHelper.DisplayValue newClass, "pSint16"
  287. scriptHelper.VerifyValue pSint16.Value, Array (-254, -1, 0, 1, 255)
  288. ' Try an insert of a simple value
  289. pSint16.AddValues 123, wbemAddValuesInsert, 1
  290. scriptHelper.DisplayValue newClass, "pSint16"
  291. scriptHelper.VerifyValue pSint16.Value, Array (-254, 123, -1, 0, 1, 255)
  292. ' Try an insert of a complex value
  293. pSint16.AddValues Array (10, 12), wbemAddValuesInsert, 4
  294. scriptHelper.DisplayValue newClass, "pSint16"
  295. scriptHelper.VerifyValue pSint16.Value, Array (-254, 123, -1, 0, 10, 12, 1, 255)
  296. End Sub
  297. '****************************************************************
  298. '*
  299. '* TestUint32
  300. '* ==========
  301. '*
  302. '* Test AddValues for uint32 arrays
  303. '*
  304. '****************************************************************
  305. Sub TestUint32
  306. on error resume next
  307. ' Try an add of a simple value
  308. set pUint32 = newClass.Properties_("pUint32")
  309. pUint32.AddValues 0
  310. scriptHelper.DisplayValue newClass, "pUint32"
  311. scriptHelper.VerifyValue pUint32.Value, Array (0)
  312. ' Try an add of a simple value
  313. pUint32.AddValues 65535
  314. scriptHelper.DisplayValue newClass, "pUint32"
  315. scriptHelper.VerifyValue pUint32.Value, Array (0,65535)
  316. ' Try an add of a complex value
  317. pUint32.AddValues Array (256, 65534)
  318. scriptHelper.DisplayValue newClass, "pUint32"
  319. scriptHelper.VerifyValue pUint32.Value, Array (0, 65535, 256, 65534)
  320. ' Try an insert of a simple value
  321. pUint32.AddValues 123, wbemAddValuesInsert, 1
  322. scriptHelper.DisplayValue newClass, "pUint32"
  323. scriptHelper.VerifyValue pUint32.Value, Array (0, 123, 65535, 256, 65534)
  324. ' Try an insert of a complex value
  325. pUint32.AddValues Array (10, 12), wbemAddValuesInsert, 4
  326. scriptHelper.DisplayValue newClass, "pUint32"
  327. scriptHelper.VerifyValue pUint32.Value, Array (0, 123, 65535, 256, 10, 12, 65534)
  328. End Sub
  329. '****************************************************************
  330. '*
  331. '* TestSint32
  332. '* ==========
  333. '*
  334. '* Test AddValues for sint32 arrays
  335. '*
  336. '****************************************************************
  337. Sub TestSint32
  338. on error resume next
  339. ' Try an add of a simple value
  340. set pSint32 = newClass.Properties_("pSint32")
  341. pSint32.AddValues -65534
  342. scriptHelper.DisplayValue newClass, "pSint32"
  343. scriptHelper.VerifyValue pSint32.Value, Array (-65534)
  344. ' Try an add of a simple value
  345. pSint32.AddValues -1
  346. scriptHelper.DisplayValue newClass, "pSint32"
  347. scriptHelper.VerifyValue pSint32.Value, Array (-65534, -1)
  348. ' Try an add of a complex value
  349. pSint32.AddValues Array (0, 1, 65535)
  350. scriptHelper.DisplayValue newClass, "pSint32"
  351. scriptHelper.VerifyValue pSint32.Value, Array (-65534, -1, 0, 1, 65535)
  352. ' Try an insert of a simple value
  353. pSint32.AddValues 123, wbemAddValuesInsert, 1
  354. scriptHelper.DisplayValue newClass, "pSint32"
  355. scriptHelper.VerifyValue pSint32.Value, Array (-65534, 123, -1, 0, 1, 65535)
  356. ' Try an insert of a complex value
  357. pSint32.AddValues Array (10, 12), wbemAddValuesInsert, 4
  358. scriptHelper.DisplayValue newClass, "pSint32"
  359. scriptHelper.VerifyValue pSint32.Value, Array (-65534, 123, -1, 0, 10, 12, 1, 65535)
  360. End Sub
  361. '****************************************************************
  362. '*
  363. '* TestUint64
  364. '* ==========
  365. '*
  366. '* Test AddValues for uint64 arrays
  367. '*
  368. '****************************************************************
  369. Sub TestUint64
  370. on error resume next
  371. ' Try an add of a simple value
  372. set pUint64 = newClass.Properties_("pUint64")
  373. pUint64.AddValues "0"
  374. scriptHelper.DisplayValue newClass, "pUint64"
  375. scriptHelper.VerifyValue pUint64.Value, Array ("0")
  376. ' Try an add of a simple value
  377. pUint64.AddValues "6553565535"
  378. scriptHelper.DisplayValue newClass, "pUint64"
  379. scriptHelper.VerifyValue pUint64.Value, Array ("0","6553565535")
  380. ' Try an add of a complex value
  381. pUint64.AddValues Array ("256", "65534")
  382. scriptHelper.DisplayValue newClass, "pUint64"
  383. scriptHelper.VerifyValue pUint64.Value, Array ("0", "6553565535", "256", "65534")
  384. ' Try an insert of a simple value
  385. pUint64.AddValues "123", wbemAddValuesInsert, 1
  386. scriptHelper.DisplayValue newClass, "pUint64"
  387. scriptHelper.VerifyValue pUint64.Value, Array ("0", "123", "6553565535", "256", "65534")
  388. ' Try an insert of a complex value
  389. pUint64.AddValues Array ("10", "12"), wbemAddValuesInsert, 4
  390. scriptHelper.DisplayValue newClass, "pUint64"
  391. scriptHelper.VerifyValue pUint64.Value, Array ("0", "123", "6553565535", "256", "10", "12", "65534")
  392. End Sub
  393. '****************************************************************
  394. '*
  395. '* TestSint64
  396. '* ==========
  397. '*
  398. '* Test AddValues for sint64 arrays
  399. '*
  400. '****************************************************************
  401. Sub TestSint64
  402. on error resume next
  403. ' Try an add of a simple value
  404. set pSint64 = newClass.Properties_("pSint64")
  405. pSint64.AddValues "0"
  406. scriptHelper.DisplayValue newClass, "pSint64"
  407. scriptHelper.VerifyValue pSint64.Value, Array ("0")
  408. ' Try an add of a simple value
  409. pSint64.AddValues "-6553565535"
  410. scriptHelper.DisplayValue newClass, "pSint64"
  411. scriptHelper.VerifyValue pSint64.Value, Array ("0","-6553565535")
  412. ' Try an add of a complex value
  413. pSint64.AddValues Array ("256", "6553465534")
  414. scriptHelper.DisplayValue newClass, "pSint64"
  415. scriptHelper.VerifyValue pSint64.Value, Array ("0", "-6553565535", "256", "6553465534")
  416. ' Try an insert of a simple value
  417. pSint64.AddValues "123", wbemAddValuesInsert, 1
  418. scriptHelper.DisplayValue newClass, "pSint64"
  419. scriptHelper.VerifyValue pSint64.Value, Array ("0", "123", "-6553565535", "256", "6553465534")
  420. ' Try an insert of a complex value
  421. pSint64.AddValues Array ("10", "12"), wbemAddValuesInsert, 4
  422. scriptHelper.DisplayValue newClass, "pSint64"
  423. scriptHelper.VerifyValue pSint64.Value, Array ("0", "123", "-6553565535", "256", "10", "12", "6553465534")
  424. End Sub
  425. '****************************************************************
  426. '*
  427. '* TestReal32
  428. '* ==========
  429. '*
  430. '* Test AddValues for real32 arrays
  431. '*
  432. '****************************************************************
  433. Sub TestReal32
  434. on error resume next
  435. ' Try an add of a simple value
  436. set pReal32 = newClass.Properties_("pReal32")
  437. pReal32.AddValues 0.0
  438. scriptHelper.DisplayValue newClass, "pReal32"
  439. scriptHelper.VerifyValue pReal32.Value, Array (0.0)
  440. ' Try an add of a simple value
  441. pReal32.AddValues 65535.34
  442. scriptHelper.DisplayValue newClass, "pReal32"
  443. scriptHelper.VerifyValue pReal32.Value, Array (0.0,65535.34)
  444. ' Try an add of a complex value
  445. pReal32.AddValues Array (-2.56, -65.534)
  446. scriptHelper.DisplayValue newClass, "pReal32"
  447. scriptHelper.VerifyValue pReal32.Value, Array (0.0, 65535.34, -2.56, -65.534)
  448. ' Try an insert of a simple value
  449. pReal32.AddValues 1.23, wbemAddValuesInsert, 1
  450. scriptHelper.DisplayValue newClass, "pReal32"
  451. scriptHelper.VerifyValue pReal32.Value, Array (0.0, 1.23, 65535.34, -2.56, -65.534)
  452. ' Try an insert of a complex value
  453. pReal32.AddValues Array (1.0, .12), wbemAddValuesInsert, 4
  454. scriptHelper.DisplayValue newClass, "pReal32"
  455. scriptHelper.VerifyValue pReal32.Value, Array (0.0, 1.23, 65535.34, -2.56, 1.0, .12, -65.534)
  456. End Sub
  457. '****************************************************************
  458. '*
  459. '* TestReal64
  460. '* ==========
  461. '*
  462. '* Test AddValues for real64 arrays
  463. '*
  464. '****************************************************************
  465. Sub TestReal64
  466. on error resume next
  467. ' Try an add of a simple value
  468. set pReal64 = newClass.Properties_("pReal64")
  469. pReal64.AddValues 0.0
  470. scriptHelper.DisplayValue newClass, "pReal64"
  471. scriptHelper.VerifyValue pReal64.Value, Array (0.0)
  472. ' Try an add of a simple value
  473. pReal64.AddValues 65535.343434
  474. scriptHelper.DisplayValue newClass, "pReal64"
  475. scriptHelper.VerifyValue pReal64.Value, Array (0.0,65535.343434)
  476. ' Try an add of a complex value
  477. pReal64.AddValues Array (-2.56, -65.534534)
  478. scriptHelper.DisplayValue newClass, "pReal64"
  479. scriptHelper.VerifyValue pReal64.Value, Array (0.0, 65535.343434, -2.56, -65.534534)
  480. ' Try an insert of a simple value
  481. pReal64.AddValues 1.23, wbemAddValuesInsert, 1
  482. scriptHelper.DisplayValue newClass, "pReal64"
  483. scriptHelper.VerifyValue pReal64.Value, Array (0.0, 1.23, 65535.343434, -2.56, -65.534534)
  484. ' Try an insert of a complex value
  485. pReal64.AddValues Array (1.0, .12), wbemAddValuesInsert, 4
  486. scriptHelper.DisplayValue newClass, "pReal64"
  487. scriptHelper.VerifyValue pReal64.Value, Array (0.0, 1.23, 65535.343434, -2.56, 1.0, .12, -65.534534)
  488. End Sub
  489. '****************************************************************
  490. '*
  491. '* TestBoolean
  492. '* ===========
  493. '*
  494. '* Test AddValues for boolean arrays
  495. '*
  496. '****************************************************************
  497. Sub TestBoolean
  498. on error resume next
  499. ' Try an add of a simple value
  500. set pBoolean = newClass.Properties_("pBoolean")
  501. pBoolean.AddValues true
  502. scriptHelper.DisplayValue newClass, "pBoolean"
  503. scriptHelper.VerifyValue pBoolean.Value, Array (true)
  504. ' Try an add of a simple value
  505. pBoolean.AddValues false
  506. scriptHelper.DisplayValue newClass, "pBoolean"
  507. scriptHelper.VerifyValue pBoolean.Value, Array (true, false)
  508. ' Try an add of a complex value
  509. pBoolean.AddValues Array (false, true, false, false, true, true)
  510. scriptHelper.DisplayValue newClass, "pBoolean"
  511. scriptHelper.VerifyValue pBoolean.Value, Array (true, false, false, true, false, false, true, true)
  512. ' Try an insert of a simple value
  513. pBoolean.AddValues false, wbemAddValuesInsert, 1
  514. scriptHelper.DisplayValue newClass, "pBoolean"
  515. scriptHelper.VerifyValue pBoolean.Value, Array (true, false, false, false, true, false, false, true, true)
  516. ' Try an insert of a complex value
  517. pBoolean.AddValues Array (true, false), wbemAddValuesInsert, 4
  518. scriptHelper.DisplayValue newClass, "pBoolean"
  519. scriptHelper.VerifyValue pBoolean.Value, Array (true, false, false, false, true, false, true, false, false, true, true)
  520. End Sub
  521. '****************************************************************
  522. '*
  523. '* TestDatetime
  524. '* ============
  525. '*
  526. '* Test AddValues for datetime arrays
  527. '*
  528. '****************************************************************
  529. Sub TestDatetime
  530. on error resume next
  531. ' Try an add of a simple value
  532. set pDatetime = newClass.Properties_("pDatetime")
  533. pDatetime.AddValues "20000120195632.000000-480"
  534. scriptHelper.DisplayValue newClass, "pDatetime"
  535. scriptHelper.VerifyValue pDatetime.Value, Array ("20000120195632.000000-480")
  536. ' Try an add of a simple value
  537. pDatetime.AddValues "20000120195632.000000+480"
  538. scriptHelper.DisplayValue newClass, "pDatetime"
  539. scriptHelper.VerifyValue pDatetime.Value, Array ("20000120195632.000000-480", "20000120195632.000000+480")
  540. if err <> 0 then scriptHelper.writeErrorToLog err, "Bar"
  541. ' Try an add of a complex value
  542. pDatetime.AddValues Array ("20000120195632.000000-480", "20000120195632.000000-480")
  543. scriptHelper.DisplayValue newClass, "pDatetime"
  544. scriptHelper.VerifyValue pDatetime.Value, Array ("20000120195632.000000-480", _
  545. "20000120195632.000000+480", "20000120195632.000000-480", "20000120195632.000000-480")
  546. ' Try an insert of a simple value
  547. pDatetime.AddValues "20000120195612.000000+480", wbemAddValuesInsert, 1
  548. scriptHelper.DisplayValue newClass, "pDatetime"
  549. scriptHelper.VerifyValue pDatetime.Value, Array ("20000120195632.000000-480", "20000120195612.000000+480", _
  550. "20000120195632.000000+480", "20000120195632.000000-480", "20000120195632.000000-480")
  551. ' Try an insert of a complex value
  552. pDatetime.AddValues Array ("20010120195612.000000+480", "20020120195612.000000+480"), wbemAddValuesInsert, 4
  553. scriptHelper.DisplayValue newClass, "pDatetime"
  554. scriptHelper.VerifyValue pDatetime.Value, Array ("20000120195632.000000-480", "20000120195612.000000+480", _
  555. "20000120195632.000000+480", "20000120195632.000000-480", _
  556. "20010120195612.000000+480", "20020120195612.000000+480", "20000120195632.000000-480")
  557. End Sub
  558. '****************************************************************
  559. '*
  560. '* TestReference
  561. '* =============
  562. '*
  563. '* Test AddValues for reference arrays
  564. '*
  565. '****************************************************************
  566. Sub TestReference
  567. on error resume next
  568. ' Try an add of a simple value
  569. set pReference = newClass.Properties_("pReference")
  570. pReference.AddValues "root\cimv2:win32_logicaldisk"
  571. scriptHelper.DisplayValue newClass, "pReference"
  572. scriptHelper.VerifyValue pReference.Value, Array ("root\cimv2:win32_logicaldisk")
  573. ' Try an add of a simple value
  574. pReference.AddValues "root\default:__cimomidentification=@"
  575. scriptHelper.DisplayValue newClass, "pReference"
  576. scriptHelper.VerifyValue pReference.Value, Array ("root\cimv2:win32_logicaldisk", "root\default:__cimomidentification=@")
  577. ' Try an add of a complex value
  578. pReference.AddValues Array ("root\default:__cimomidentification=@", "root\cimv2:win32_logicaldisk")
  579. scriptHelper.DisplayValue newClass, "pReference"
  580. scriptHelper.VerifyValue pReference.Value, Array ("root\cimv2:win32_logicaldisk", _
  581. "root\default:__cimomidentification=@", "root\default:__cimomidentification=@", "root\cimv2:win32_logicaldisk")
  582. ' Try an insert of a simple value
  583. pReference.AddValues "\\foo\root\wibble", wbemAddValuesInsert, 1
  584. scriptHelper.DisplayValue newClass, "pReference"
  585. scriptHelper.VerifyValue pReference.Value, Array ("root\cimv2:win32_logicaldisk", "\\foo\root\wibble", _
  586. "root\default:__cimomidentification=@", "root\default:__cimomidentification=@", "root\cimv2:win32_logicaldisk")
  587. ' Try an insert of a complex value
  588. pReference.AddValues Array ("\\foo\root\wibble1", "\\foo2\root\wibble"), wbemAddValuesInsert, 4
  589. scriptHelper.DisplayValue newClass, "pReference"
  590. scriptHelper.VerifyValue pReference.Value, Array ("root\cimv2:win32_logicaldisk", "\\foo\root\wibble", _
  591. "root\default:__cimomidentification=@", "root\default:__cimomidentification=@", _
  592. "\\foo\root\wibble1", "\\foo2\root\wibble", "root\cimv2:win32_logicaldisk")
  593. End Sub
  594. '****************************************************************
  595. '*
  596. '* TestChar16
  597. '* ==========
  598. '*
  599. '* Test AddValues for char16 arrays
  600. '*
  601. '****************************************************************
  602. Sub TestChar16
  603. on error resume next
  604. ' Try an add of a simple value
  605. set pChar16 = newClass.Properties_("pChar16")
  606. pChar16.AddValues 30
  607. scriptHelper.DisplayValue newClass, "pChar16"
  608. scriptHelper.VerifyValue pChar16.Value, Array (30)
  609. ' Try an add of a simple value
  610. pChar16.AddValues 31
  611. scriptHelper.DisplayValue newClass, "pChar16"
  612. scriptHelper.VerifyValue pChar16.Value, Array (30, 31)
  613. ' Try an add of a complex value
  614. pChar16.AddValues Array (32, 33)
  615. scriptHelper.DisplayValue newClass, "pChar16"
  616. scriptHelper.VerifyValue pChar16.Value, Array (30 ,31, 32, 33)
  617. ' Try an insert of a simple value
  618. pChar16.AddValues 44, wbemAddValuesInsert, 1
  619. scriptHelper.DisplayValue newClass, "pChar16"
  620. scriptHelper.VerifyValue pChar16.Value, Array (30, 44, 31, 32, 33)
  621. ' Try an insert of a complex value
  622. pChar16.AddValues Array (55, 56), wbemAddValuesInsert, 4
  623. scriptHelper.DisplayValue newClass, "pChar16"
  624. scriptHelper.VerifyValue pChar16.Value, Array (30, 44, 31, 32, 55, 56, 33)
  625. End Sub
  626. '****************************************************************
  627. '*
  628. '* TestObject
  629. '* ==========
  630. '*
  631. '* Test AddValues for object arrays
  632. '*
  633. '****************************************************************
  634. Sub TestObject
  635. on error resume next
  636. ' Get an object to plug in
  637. set sysClass = GetObject("winmgmts:__SystemClass")
  638. set disk = GetObject("winmgmts:Win32_logicaldisk")
  639. set process = GetObject("winmgmts:Win32_process")
  640. ' Try an add of a simple value
  641. set pObject = newClass.Properties_("pObject")
  642. pObject.AddValues sysClass
  643. scriptHelper.DisplayValue newClass, "pObject"
  644. scriptHelper.VerifyValue pObject.Value, Array (sysClass)
  645. ' Try an add of a simple value
  646. pObject.AddValues disk
  647. scriptHelper.DisplayValue newClass, "pObject"
  648. scriptHelper.VerifyValue pObject.Value, Array (sysClass, disk)
  649. ' Try an add of a complex value
  650. pObject.AddValues Array (sysClass, sysClass)
  651. scriptHelper.DisplayValue newClass, "pObject"
  652. scriptHelper.VerifyValue pObject.Value, Array (sysClass, disk, sysClass, sysClass)
  653. ' Try an insert of a simple value
  654. pObject.AddValues process, wbemAddValuesInsert, 1
  655. scriptHelper.DisplayValue newClass, "pObject"
  656. scriptHelper.VerifyValue pObject.Value, Array (sysClass, process, disk, sysClass, sysClass)
  657. ' Try an insert of a complex value
  658. pObject.AddValues Array (disk, process), wbemAddValuesInsert, 4
  659. scriptHelper.DisplayValue newClass, "pObject"
  660. scriptHelper.VerifyValue pObject.Value, Array (sysClass, process, disk, sysClass, disk, process, sysClass)
  661. End Sub
  662. </script>
  663. </job>