tests/PSTS.account.Tests.ps1

describe 'Add-PSTSAccount' {

    # Arrange
    Mock -ModuleName PSTS -Verifiable read-host -MockWith  {  return  (ConvertTo-SecureString -AsPlainText -String "test" -Force) }

      $credPath = "$([Environment]::GetFolderPath('ApplicationData'))/REST-Devops"

      if ((Test-Path -Path "$($credPath)/fakeAccount" ) -eq $true) { del $credPath/fakeAccount }


    # Act
    Add-PSTSAccount -account "fakeAccount" -endpoint "fakeEndPoint"


    it "should return fakeAccount and $true" {
         [Environment]::GetEnvironmentVariable("ACCOUNT") | should -Be fakeAccount

    }
}

describe 'Set-PSTSAccount' {

    # Act
    Set-PSTSAccount -account "fakeAccount" -endpoint "fakeEndPoint"


    it "should return fakeAccount and $true" {
         [Environment]::GetEnvironmentVariable("ACCOUNT") | should -Be fakeAccount

    }
}

describe 'Remove-PSTSAccount' {

    # Act
    Remove-PSTSAccount -account "fakeAccount"


    it "should return fakeAccount and $false" {

        $credFile = "$([Environment]::GetFolderPath('ApplicationData'))/REST-Devops/fakeAccount"

        (Test-Path -Path $credFile ) | should -Be $false
    }
}