VDK unit tests are a great way to learn how to use the VDK library. To see
unit tests, you can visit them here.
The VDK uses the scriptunit program for unit testing. You can even execute the
unit tests yourself or even build unit tests for your own VDK code. An example of
a unit test for the class vdk.lang.collections.clsVdkMap is below.
'This file has been auto generated by the VDK unit test framework
'Stub auto generated from code in file: g:\vdk\vdk\lang\collections\clsVdkMap.vbs
'For each procedure in the original code file, there will be a unit test stub
'The unit test stub names are generated according to formula: test_[Class_Name]_[Procedure_Name]
ExecuteGlobal createobject("wsh.vdk.initialize").initialize
import "vdk.lang.collections.clsVdkMap"
public sub test_clsVdkMap_getCount
'TODO - write your unit test code below
set objMap = new clsVdkMap
Assert.isEqual objMap.getCount(), 0
objMap.put 1, "Jason"
Assert.isEqual objMap.getCount(), 1
End Sub
public sub test_clsVdkMap_hasKeys
set objMap = new clsVdkMap
Assert.isFalse objMap.hasKeys
objMap.put 1, "Jason"
Assert.isTrue objMap.hasKeys
End Sub
public sub test_clsVdkMap_hasKey
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isTrue objMap.HasKey(1)
End Sub
public sub test_clsVdkMap_getKeyIndex
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isTrue objMap.HasKey(1)
Assert.isEqual objMap.getKeyIndex (1), 0
objMap.put 2, "Ely"
Assert.isEqual objMap.getKeyIndex (2),1
Assert.isEqual objMap.getKeyIndex (100),-1
End Sub
public sub test_clsVdkMap_hasValue
'TODO - write your unit test code below
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isTrue objMap.hasValue("Jason")
Assert.isFalse objMap.hasValue("Ely")
End Sub
public sub test_clsVdkMap_getKeyValue
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isEqual objMap.getKeyValue(1), "Jason"
Assert.isEqual objMap.getKeyValue(2), vbEmpty
End Sub
public sub test_clsVdkMap_getKeyTypeOverride
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isEqual objMap.getKeyTypeOverride, vbEmpty
End Sub
public sub test_clsVdkMap_getValueTypeOverride
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isEqual objMap.getValueTypeOverride, vbEmpty
End Sub
public sub test_clsVdkMap_setTypeOverride
set objMap = new clsVdkMap
objMap.setTypeOverride typename(1), typename("Jason")
Assert.isEqual objMap.getKeyTypeOverride,typename(1)
Assert.isEqual objMap.getValueTypeOverride, typename("Jason")
End Sub
public sub test_clsVdkMap_put
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isEqual objMap.getCount(), 1
objMap.put 1, "Ely"
Assert.isEqual objMap.getKeyValue(1), "Ely"
End Sub
public sub test_clsVdkMap_remove
set objMap = new clsVdkMap
objMap.put 1, "Jason"
Assert.isEqual objMap.getCount(), 1
objMap.remove 2
Assert.isEqual objMap.getCount(), 1
objMap.remove 1
Assert.isEqual objMap.getCount(), 0
End Sub
public sub test_clsVdkMap_clear
set objMap = new clsVdkMap
objMap.put 1, "Jason"
objMap.put 2, "Jason"
Assert.isEqual objMap.getCount(), 2
objMap.clear
Assert.isEqual objMap.getCount(), 0
End Sub
public sub test_clsVdkMap_getKeySet
set objMap = new clsVdkMap
objMap.put 1, "Jason"
objMap.put 2, "Ely"
set objKeySet = objMap.getKeySet
Assert.isEqual lcase(typename(objKeySet)), lcase("clsArrayList")
Assert.isEqual objKeySet.getCount(), 2
Assert.IsEqual objKeySet.getItemAt(0), 1
Assert.IsEqual objKeySet.getItemAt(1), 2
End Sub
public sub test_clsVdkMap_getValueSet
set objMap = new clsVdkMap
objMap.put 1, "Jason"
objMap.put 2, "Ely"
set objValueSet = objMap.getValueSet
Assert.isEqual lcase(typename(objValueSet)), lcase("clsArrayList")
Assert.isEqual objValueSet.getCount(), 2
Assert.IsEqual objValueSet.getItemAt(0), "Jason"
Assert.IsEqual objValueSet.getItemAt(1), "Ely"
End Sub
Each VDK class method has a unit test which you can read to understand the method mechanics
in detail.
Latest News
VDK version 2.0.0 is scheduled for release on 01/12/2017. To see
the list of new features, click
here.
Users are welcome to request new features in our
forum.
Submissions for new requests will end on 30/09/2017.