Public/tests/ValidateUserInput.Tests.ps1
BeforeAll { #dot source the location of the function we will be testing . "PowerShell/FaradayCage/Private/Utilities.ps1" } Describe 'Test-UserInput' { It 'Given a virtual machine name that meets requirements, the validation function should not throw an error' { $VMName = "fcage" {Test-UserInput -FCageName $VMName} | Should -Not -Throw } It 'Given a virtual machine name that is empty, the validation function should throw an error' { $VMName = "" {Test-UserInput -FCageName $VMName} | Should -Throw "The name '$VMName' cannot be empty or contain special characters. Exiting." } It 'Given a virtual machine name that contains a special character, the validation function should throw an error' { $VMName = "fc@ge" {Test-UserInput -FCageName $VMName} | Should -Throw "The name '$VMName' cannot be empty or contain special characters. Exiting." } It 'Given a virtual machine name that ends with a hyphen, the validation function throws an error' { $VMName = "fcage-" {Test-UserInput -FCageName $VMName} | Should -Throw "The name '$VMName' cannot end with a hyphen. Exiting." } } |