Tests/Varibill.SourceCollector.Core.Manual.ps1

. $PSScriptRoot/../Public/Install-ModuleIfNeeded.ps1 

Install-ModuleIfNeeded -Name "Microsoft.PowerShell.SecretManagement"
Install-ModuleIfNeeded -Name "Microsoft.PowerShell.SecretStore"
Install-ModuleIfNeeded -Name "Pester" -Update
Install-ModuleIfNeeded -Name "Varibill.SourceCollector.Core" -Update

$ErrorActionPreference = "Stop"
$VerbosePreference = 'Continue'
#$VerbosePreference = 'SilentlyContinue'

#TODO make the parameters environment variables
$global:SourceCollectorAPI  = "https://qasc.varibill.com/"
$global:TenantKey           = "38166877-6352-4036-83b8-638b6e0edb0c"
$global:SourceCollectorKey  = "ef739881-d494-480f-a1fd-c10f2332485c"
$global:SourceCollectorSecret = (Get-Secret -Name SourceCollectorSecret) | ConvertFrom-SecureString -AsPlainText

$unrated = New-UnratedSourceData -SourceCollectorAPI $global:SourceCollectorAPI -TenantKey $global:TenantKey -SourceCollectorKey $global:SourceCollectorKey -SourceCollectorSecret $global:SourceCollectorSecret -MaxRecordsPerFile 1000 -Verbose

# Add multiple records
1..10000 | ForEach-Object {
    $unrated.AddUnratedSourceData("Client$_", "Prod$_", "Rec$_", "UID$_", (Get-Date), $_, "Tag$_")
}
$unrated.SaveData()
# Post records (saves .rdy files and posts them)
$unrated.PostSourceData()


# Create a RatedSourceData instance
$rated = New-RatedSourceData -SourceCollectorAPI $global:SourceCollectorAPI -TenantKey $global:TenantKey -SourceCollectorKey $global:SourceCollectorKey -SourceCollectorSecret $global:SourceCollectorSecret -Verbose

# Add multiple records
1..10000 | ForEach-Object {
    $rated.AddRatedSourceData("Client$_", "Prod$_", "Rec$_", "UID$_", (Get-Date), $_, $_*2, $_*1.5, "Tag$_")
}

$rated.SaveData()
# Post records
$rated.PostSourceData()