Testing/Get-TestCodeunitsInContainer.ps1

function Get-TestCodeunitsInContainer {
    param (
        # Container to load test codeunits into
        [Parameter(Mandatory=$false)]
        [string]
        $ContainerName = "",
        # Credentials to use to connect to web service
        [Parameter(Mandatory=$false)]
        [PSCredential]
        $Credential = (New-CredentialFromEnvironmentJson),
        # Name of the test suite to add the test codeunits to
        [Parameter(Mandatory=$false)]
        [string]
        $TestSuite = '',
        # Start of the range of objects to add
        [Parameter(Mandatory=$true)]
        [int]
        $StartId,
        # End of the range of objects to add
        [Parameter(Mandatory=$true)]
        [int]
        $EndId
    )

    Install-BuildHelper -ContainerName $ContainerName
    $CompanyName = Get-ContainerCompanyToTest -ContainerName $ContainerName
    
    [version]$BCFallPlatform = '15.0.0.0'
    [Version]$platform = [Version]::Parse((Get-AppKeyValue -SourcePath (Get-Location) -KeyName 'platform'))
    if ($platform -ge $BCFallPlatform){
        $Url = "http://{0}:7047/BC/WS/{1}/Codeunit/NavxAutomatedTestManagement" -f (Get-NavContainerIpAddress -containerName $ContainerName), $CompanyName
    } else{
        $Url = "http://{0}:7047/NAV/WS/{1}/Codeunit/NavxAutomatedTestManagement" -f (Get-NavContainerIpAddress -containerName $ContainerName), $CompanyName
    }
    
    Write-Host "Calling $Url to retrieve test codeunits"
    $AutomatedTestMgt = New-WebServiceProxy -Uri $Url -Credential $Credential
    $AutomatedTestMgt.ClearTestSuite($TestSuite)
    $AutomatedTestMgt.GetTests($TestSuite,$StartId,$EndId)
}

Export-ModuleMember -Function Get-TestCodeunitsInContainer