tests/functions/Get-D365CeODataEntityDataByKey.Tests.ps1
Describe "Get-D365CeODataEntityDataByKey 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 Get-D365CeODataEntityDataByKey).ParameterSets.Name | Should -Be 'Default', 'Specific' } It 'Should have the expected parameter EntityName' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['EntityName'] $parameter.Name | Should -Be 'EntityName' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be 'Specific' $parameter.ParameterSets.Keys | Should -Contain 'Specific' $parameter.ParameterSets['Specific'].IsMandatory | Should -Be $True $parameter.ParameterSets['Specific'].Position | Should -Be -2147483648 $parameter.ParameterSets['Specific'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['Specific'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['Specific'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter Key' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['Key'] $parameter.Name | Should -Be 'Key' $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be 'Specific' $parameter.ParameterSets.Keys | Should -Contain 'Specific' $parameter.ParameterSets['Specific'].IsMandatory | Should -Be $True $parameter.ParameterSets['Specific'].Position | Should -Be -2147483648 $parameter.ParameterSets['Specific'].ValueFromPipeline | Should -Be $False $parameter.ParameterSets['Specific'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['Specific'].ValueFromRemainingArguments | Should -Be $False } It 'Should have the expected parameter ODataQuery' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['ODataQuery'] $parameter.Name | Should -Be 'ODataQuery' $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 Tenant' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['Tenant'] $parameter.Name | Should -Be 'Tenant' $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 URL' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['URL'] $parameter.Name | Should -Be 'URL' $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 ClientId' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['ClientId'] $parameter.Name | Should -Be 'ClientId' $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 ClientSecret' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['ClientSecret'] $parameter.Name | Should -Be 'ClientSecret' $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 EnableException' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).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 OutputAsJson' { $parameter = (Get-Command Get-D365CeODataEntityDataByKey).Parameters['OutputAsJson'] $parameter.Name | Should -Be 'OutputAsJson' $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 Default" { <# Default - Default -ODataQuery -Tenant -URL -ClientId -ClientSecret -EnableException -OutputAsJson #> } Describe "Testing parameterset Specific" { <# Specific -EntityName -Key Specific -EntityName -Key -ODataQuery -Tenant -URL -ClientId -ClientSecret -EnableException -OutputAsJson #> } } |