Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfcomponent>
- <cfproperty name="UITestsRoot" type="string" default="">
- <cffunction name="init" access="public" returntype="UITests.dataproviders.DataProvider" output="false">
- <cfreturn this>
- </cffunction>
- <cffunction name="setUITestsRoot" access="public" returntype="void" output="false">
- <cfargument name="path" type="string" required="false" default="#application.UITestsRoot#">
- <cfset this.UITestsRoot = arguments.path>
- </cffunction>
- <cffunction name="getDataProvidersIndex" access="public" returntype="query" output="false">
- <cfspreadsheet action="read" src="#this.UITestsRoot#\dataproviders\datafiles\DataProviders_Index.xls" excludeheaderrow="true" headerrow="1" sheet="1" query="local.dpIndex">
- <cfreturn local.dpIndex>
- </cffunction>
- <cffunction name="createDataProviders" access="public" returntype="struct" output="false">
- <cfset local.dpIndex = getDataProvidersIndex()>
- <cfset local.dataProviders = {}>
- <cfset local.datafile = "">
- <cfset local.dpm = createObject("component","UITests.dataproviders.DataProviderManager")>
- <cfloop from="1" to="#local.dpIndex.recordCount#" index="local.i">
- <cfset local.datafile = "#this.UITestsRoot#\dataproviders\datafiles\#local.dpIndex.webtop[local.i]#\#local.dpIndex.filename[local.i]#">
- <cfset local.datafile = replace(local.datafile,"\All\","\","one")>
- <cfif not fileexists(local.datafile)>
- <cfthrow message="Data File #listlast(local.datafile,'\')# Not Found" detail="Expected to find #local.datafile#">
- </cfif>
- <cfswitch expression="#dpIndex.dataSet[local.i]#">
- <cfcase value="All">
- <cfset local.dpm.setDataProvider(local.datafile,local.dpIndex.sheetName[local.i],local.dpIndex.tableName[local.i])>
- <cfset local.dataProviders['#local.dpIndex.name[local.i]#'] = local.dpm.getData()>
- </cfcase>
- <cfcase value="Range">
- <cfset local.dpm.setDataProvider(local.datafile,local.dpIndex.sheetName[local.i],local.dpIndex.tableName[local.i])>
- <cfset local.dataProviders['#local.dpIndex.name[local.i]#'] = local.dpm.getDataByRange(local.dpIndex.startRow[local.i],local.dpIndex.endRow[local.i])>
- </cfcase>
- <cfcase value="Row">
- <cfset local.dpm.setDataProvider(local.datafile,local.dpIndex.sheetName[local.i],local.dpIndex.tableName[local.i])>
- <cfset local.dataProviders['#local.dpIndex.name[local.i]#'] = local.dpm.getDataAtRow(local.dpIndex.startRow[local.i])>
- </cfcase>
- </cfswitch>
- </cfloop>
- <cfreturn local.dataProviders>
- </cffunction>
- </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement