functions/Get-SolutionImportLog.Tests.ps1

$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"

Describe "Get-SolutionImportLog" {
  Context "Given an ImportJob existing in CRM CRMRECRUITTEST with an ID of 60255876-6aae-e511-80c2-0050569b65f8" {
    It "Should return the formatted xml results and export them if specified" {
      $exportPath = "TestDrive:\logs\log.xml"
      # $exportPath = "C:\repos\ps\crm-ci\log.xml"
      $id = "60255876-6aae-e511-80c2-0050569b65f8"
      # $id = "34412c0d-ac41-49ed-a1db-ca8ae5450e1f"
      $results = Get-SolutionImportLog `
        -CrmInstance CRMRECRUITTEST `
        -ImportJobId $id `
        -ExportPath $exportPath `
        -Credential (Get-Credential -UserName $env:USERNAME -Message "Please provide CRM Credentials")
      
      $results | Should -Not -BeNullOrEmpty
      
      Test-Path $exportPath | Should -Be $true
      $contents = Get-Content $exportPath
      $contents | Should -Be $results
    }
  }
}