tests/functions/Invoke-D365SqlScript.Tests.ps1
Describe "Invoke-D365SqlScript Unit Tests" -Tag "Unit" { BeforeAll { # Place here all things needed to prepare for the tests } AfterAll { # Here is where all the cleanup tasks go } Describe "Ensuring unchanged command signature" { It "should have the expected parameter sets" { (Get-Command Invoke-D365SqlScript).ParameterSets.Name | Should -Be 'FilePath', 'Command' } It 'Should have the expected parameter FilePath' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['FilePath'] $parameter.Name | Should -Be 'FilePath' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be 'FilePath' $parameter.ParameterSets.Keys | Should -Contain 'FilePath' $parameter.ParameterSets['FilePath'].IsMandatory | Should -Be $True $parameter.ParameterSets['FilePath'].Position | Should -Be 1 $parameter.ParameterSets['FilePath'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['FilePath'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['FilePath'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter Command' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['Command'] $parameter.Name | Should -Be 'Command' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be 'Command' $parameter.ParameterSets.Keys | Should -Contain 'Command' $parameter.ParameterSets['Command'].IsMandatory | Should -Be $True $parameter.ParameterSets['Command'].Position | Should -Be 1 $parameter.ParameterSets['Command'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['Command'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['Command'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter DatabaseServer' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['DatabaseServer'] $parameter.Name | Should -Be 'DatabaseServer' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter DatabaseName' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['DatabaseName'] $parameter.Name | Should -Be 'DatabaseName' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter SqlUser' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['SqlUser'] $parameter.Name | Should -Be 'SqlUser' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter SqlPwd' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['SqlPwd'] $parameter.Name | Should -Be 'SqlPwd' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter TrustedConnection' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['TrustedConnection'] $parameter.Name | Should -Be 'TrustedConnection' $parameter.ParameterType.ToString() | Should -Be System.Boolean $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter EnableException' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['EnableException'] $parameter.Name | Should -Be 'EnableException' $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter NoPooling' { $parameter = (Get-Command Invoke-D365SqlScript).Parameters['NoPooling'] $parameter.Name | Should -Be 'NoPooling' $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } } Describe "Testing parameterset FilePath" { <# FilePath -FilePath FilePath -FilePath -DatabaseServer -DatabaseName -SqlUser -SqlPwd -TrustedConnection -EnableException -NoPooling #> } Describe "Testing parameterset Command" { <# Command -Command Command -Command -DatabaseServer -DatabaseName -SqlUser -SqlPwd -TrustedConnection -EnableException -NoPooling #> } } |