Functions/Convert-Base64EncodedBytesToFile.Tests.ps1

describe "BitTitan.Runbooks.Common/Convert-Base64EncodedBytesToFile" -Tag "module", "unit" {

    # Import the function to test
    . "$($PSScriptRoot)\Convert-Base64EncodedBytesToFile.ps1"

    it "converts the Base64 encoded bytes to a file" {
        # Create the file
        $path = Join-Path $env:TEMP "$(New-Guid).txt"

        # Call the function
        Convert-Base64EncodedBytesToFile -Base64Content "SGVsbG8gd29ybGQh" -Path $path

        # Verify the result
        Get-Content -Path $path | Should Be "Hello world!"

        # Remove the file
        Remove-Item -Path $path -Force -Confirm:$false
    }
}