src/functions/Get-CrmConnectionString.Tests.ps1

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

Describe "Get-CrmConnectionString" {
    It "Returns either a connection string or just the url depending on the -UrlOnly switch" {
      [string]$connString = Get-CrmConnectionString -CrmInstance CRMADVISE  
      $connString.StartsWith("AuthType=AD;Url=") | Should -Be $true
      
      [string]$urlOnly = Get-CrmConnectionString -CrmInstance CRMADVISE -UrlOnly
      $urlOnly.StartsWith("https://") | Should -Be $true
    }
    It "Returns the correct address based on the crm instance" {
      [string]$connString = Get-CrmConnectionString -CrmInstance CRMADVISETEST
      $connString | Should -Be "AuthType=AD;Url=https://advisedevcrm.regent.edu/CRMADVISETEST;"
    }
}