Skip to content

Commit d7a512a

Browse files
committed
Add CatalogCollation property to enum properties in database property tests for improved type safety
1 parent df95655 commit d7a512a

File tree

1 file changed

+122
-38
lines changed

1 file changed

+122
-38
lines changed

tests/Unit/Public/Test-SqlDscDatabaseProperty.Tests.ps1

Lines changed: 122 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ BeforeDiscovery {
106106
# String Properties
107107
'AvailabilityGroupName' = @{ Type = 'String'; TestValue = 'TestAG'; ExpectedValue = 'TestAG' }
108108
'AzureServiceObjective' = @{ Type = 'String'; TestValue = 'S1'; ExpectedValue = 'S1' }
109-
'CatalogCollation' = @{ Type = 'Enum'; TestValue = [Microsoft.SqlServer.Management.Smo.CatalogCollationType]::DatabaseDefault; ExpectedValue = [Microsoft.SqlServer.Management.Smo.CatalogCollationType]::DatabaseDefault }
110109
'Collation' = @{ Type = 'String'; TestValue = 'SQL_Latin1_General_CP1_CI_AS'; ExpectedValue = 'SQL_Latin1_General_CP1_CI_AS' }
111110
'DboLogin' = @{ Type = 'String'; TestValue = 'sa'; ExpectedValue = 'sa' }
112111
'DefaultFileGroup' = @{ Type = 'String'; TestValue = 'PRIMARY'; ExpectedValue = 'PRIMARY' }
@@ -144,6 +143,7 @@ BeforeDiscovery {
144143

145144
# Enum Properties
146145
'AvailabilityDatabaseSynchronizationState' = @{ Type = 'Enum'; TestValue = [Microsoft.SqlServer.Management.Smo.AvailabilityDatabaseSynchronizationState]::Synchronized; ExpectedValue = [Microsoft.SqlServer.Management.Smo.AvailabilityDatabaseSynchronizationState]::Synchronized }
146+
'CatalogCollation' = @{ Type = 'Enum'; TestValue = [Microsoft.SqlServer.Management.Smo.CatalogCollationType]::DatabaseDefault; ExpectedValue = [Microsoft.SqlServer.Management.Smo.CatalogCollationType]::DatabaseDefault }
147147
'ChangeTrackingRetentionPeriodUnits' = @{ Type = 'Enum'; TestValue = [Microsoft.SqlServer.Management.Smo.RetentionPeriodUnits]::Days; ExpectedValue = [Microsoft.SqlServer.Management.Smo.RetentionPeriodUnits]::Days }
148148
'CompatibilityLevel' = @{ Type = 'Enum'; TestValue = [Microsoft.SqlServer.Management.Smo.CompatibilityLevel]::Version150; ExpectedValue = [Microsoft.SqlServer.Management.Smo.CompatibilityLevel]::Version150 }
149149
'ContainmentType' = @{ Type = 'Enum'; TestValue = [Microsoft.SqlServer.Management.Smo.ContainmentType]::None; ExpectedValue = [Microsoft.SqlServer.Management.Smo.ContainmentType]::None }
@@ -608,44 +608,128 @@ Describe 'Test-SqlDscDatabaseProperty' -Tag 'Public' {
608608
} -Force
609609
}
610610

611-
It 'Should support all database property parameters' {
611+
It 'Should have parameter <ParameterName> available' -ForEach @(
612+
@{ ParameterName = 'AcceleratedRecoveryEnabled' }
613+
@{ ParameterName = 'ActiveDirectory' }
614+
@{ ParameterName = 'AnsiNullDefault' }
615+
@{ ParameterName = 'AnsiNullsEnabled' }
616+
@{ ParameterName = 'AnsiPaddingEnabled' }
617+
@{ ParameterName = 'AnsiWarningsEnabled' }
618+
@{ ParameterName = 'ArithmeticAbortEnabled' }
619+
@{ ParameterName = 'AutoClose' }
620+
@{ ParameterName = 'AutoCreateIncrementalStatisticsEnabled' }
621+
@{ ParameterName = 'AutoCreateStatisticsEnabled' }
622+
@{ ParameterName = 'AutoShrink' }
623+
@{ ParameterName = 'AutoUpdateStatisticsAsync' }
624+
@{ ParameterName = 'AutoUpdateStatisticsEnabled' }
625+
@{ ParameterName = 'BrokerEnabled' }
626+
@{ ParameterName = 'CaseSensitive' }
627+
@{ ParameterName = 'ChangeTrackingAutoCleanUp' }
628+
@{ ParameterName = 'ChangeTrackingEnabled' }
629+
@{ ParameterName = 'CloseCursorsOnCommitEnabled' }
630+
@{ ParameterName = 'ConcatenateNullYieldsNull' }
631+
@{ ParameterName = 'DatabaseOwnershipChaining' }
632+
@{ ParameterName = 'DataRetentionEnabled' }
633+
@{ ParameterName = 'DateCorrelationOptimization' }
634+
@{ ParameterName = 'DelayedDurability' }
635+
@{ ParameterName = 'EncryptionEnabled' }
636+
@{ ParameterName = 'HasDatabaseEncryptionKey' }
637+
@{ ParameterName = 'HasFileInCloud' }
638+
@{ ParameterName = 'HasMemoryOptimizedObjects' }
639+
@{ ParameterName = 'HonorBrokerPriority' }
640+
@{ ParameterName = 'IsAccessible' }
641+
@{ ParameterName = 'IsDatabaseSnapshot' }
642+
@{ ParameterName = 'IsDatabaseSnapshotBase' }
643+
@{ ParameterName = 'IsDbAccessAdmin' }
644+
@{ ParameterName = 'IsDbBackupOperator' }
645+
@{ ParameterName = 'IsDbDataReader' }
646+
@{ ParameterName = 'IsDbDataWriter' }
647+
@{ ParameterName = 'IsDbDdlAdmin' }
648+
@{ ParameterName = 'IsDbDenyDataReader' }
649+
@{ ParameterName = 'IsDbDenyDataWriter' }
650+
@{ ParameterName = 'IsDbManager' }
651+
@{ ParameterName = 'IsDbOwner' }
652+
@{ ParameterName = 'IsDbSecurityAdmin' }
653+
@{ ParameterName = 'IsFabricDatabase' }
654+
@{ ParameterName = 'IsFullTextEnabled' }
655+
@{ ParameterName = 'IsLedger' }
656+
@{ ParameterName = 'IsLoginManager' }
657+
@{ ParameterName = 'IsMailHost' }
658+
@{ ParameterName = 'IsManagementDataWarehouse' }
659+
@{ ParameterName = 'IsMaxSizeApplicable' }
660+
@{ ParameterName = 'IsMirroringEnabled' }
661+
@{ ParameterName = 'IsParameterizationForced' }
662+
@{ ParameterName = 'IsReadCommittedSnapshotOn' }
663+
@{ ParameterName = 'IsSqlDw' }
664+
@{ ParameterName = 'IsSqlDwEdition' }
665+
@{ ParameterName = 'IsSystemObject' }
666+
@{ ParameterName = 'IsVarDecimalStorageFormatEnabled' }
667+
@{ ParameterName = 'IsVarDecimalStorageFormatSupported' }
668+
@{ ParameterName = 'LegacyCardinalityEstimation' }
669+
@{ ParameterName = 'LegacyCardinalityEstimationForSecondary' }
670+
@{ ParameterName = 'LocalCursorsDefault' }
671+
@{ ParameterName = 'NestedTriggersEnabled' }
672+
@{ ParameterName = 'NumericRoundAbortEnabled' }
673+
@{ ParameterName = 'ParameterSniffing' }
674+
@{ ParameterName = 'ParameterSniffingForSecondary' }
675+
@{ ParameterName = 'QueryOptimizerHotfixes' }
676+
@{ ParameterName = 'QueryOptimizerHotfixesForSecondary' }
677+
@{ ParameterName = 'QuotedIdentifiersEnabled' }
678+
@{ ParameterName = 'ReadOnly' }
679+
@{ ParameterName = 'RecursiveTriggersEnabled' }
680+
@{ ParameterName = 'RemoteDataArchiveEnabled' }
681+
@{ ParameterName = 'RemoteDataArchiveUseFederatedServiceAccount' }
682+
@{ ParameterName = 'TemporalHistoryRetentionEnabled' }
683+
@{ ParameterName = 'TransformNoiseWords' }
684+
@{ ParameterName = 'Trustworthy' }
685+
@{ ParameterName = 'WarnOnRename' }
686+
@{ ParameterName = 'AvailabilityGroupName' }
687+
@{ ParameterName = 'AzureServiceObjective' }
688+
@{ ParameterName = 'CatalogCollation' }
689+
@{ ParameterName = 'Collation' }
690+
@{ ParameterName = 'DboLogin' }
691+
@{ ParameterName = 'DefaultFileGroup' }
692+
@{ ParameterName = 'DefaultFileStreamFileGroup' }
693+
@{ ParameterName = 'DefaultFullTextCatalog' }
694+
@{ ParameterName = 'DefaultSchema' }
695+
@{ ParameterName = 'FilestreamDirectoryName' }
696+
@{ ParameterName = 'MirroringPartner' }
697+
@{ ParameterName = 'MirroringPartnerInstance' }
698+
@{ ParameterName = 'MirroringWitness' }
699+
@{ ParameterName = 'Name' }
700+
@{ ParameterName = 'Owner' }
701+
@{ ParameterName = 'PersistentVersionStoreFileGroup' }
702+
@{ ParameterName = 'PrimaryFilePath' }
703+
@{ ParameterName = 'RemoteDataArchiveCredential' }
704+
@{ ParameterName = 'RemoteDataArchiveEndpoint' }
705+
@{ ParameterName = 'RemoteDataArchiveLinkedServer' }
706+
@{ ParameterName = 'RemoteDatabaseName' }
707+
@{ ParameterName = 'UserName' }
708+
@{ ParameterName = 'ActiveConnections' }
709+
@{ ParameterName = 'ChangeTrackingRetentionPeriod' }
710+
@{ ParameterName = 'DefaultFullTextLanguage' }
711+
@{ ParameterName = 'DefaultLanguage' }
712+
@{ ParameterName = 'ID' }
713+
@{ ParameterName = 'MaxDop' }
714+
@{ ParameterName = 'MaxDopForSecondary' }
715+
@{ ParameterName = 'MirroringRedoQueueMaxSize' }
716+
@{ ParameterName = 'MirroringRoleSequence' }
717+
@{ ParameterName = 'MirroringSafetySequence' }
718+
@{ ParameterName = 'MirroringTimeout' }
719+
@{ ParameterName = 'TargetRecoveryTime' }
720+
@{ ParameterName = 'TwoDigitYearCutoff' }
721+
@{ ParameterName = 'Version' }
722+
@{ ParameterName = 'AvailabilityDatabaseSynchronizationState' }
723+
@{ ParameterName = 'ChangeTrackingRetentionPeriodUnits' }
724+
@{ ParameterName = 'CompatibilityLevel' }
725+
@{ ParameterName = 'ContainmentType' }
726+
@{ ParameterName = 'FilestreamNonTransactedAccess' }
727+
@{ ParameterName = 'PageVerify' }
728+
@{ ParameterName = 'RecoveryModel' }
729+
@{ ParameterName = 'UserAccess' }
730+
) {
612731
$command = Get-Command -Name 'Test-SqlDscDatabaseProperty'
613-
614-
# Test that all expected parameters are available (using the testPropertyData from BeforeDiscovery)
615-
$expectedParameters = @(
616-
'AcceleratedRecoveryEnabled', 'ActiveDirectory', 'AnsiNullDefault', 'AnsiNullsEnabled', 'AnsiPaddingEnabled',
617-
'AnsiWarningsEnabled', 'ArithmeticAbortEnabled', 'AutoClose', 'AutoCreateIncrementalStatisticsEnabled',
618-
'AutoCreateStatisticsEnabled', 'AutoShrink', 'AutoUpdateStatisticsAsync', 'AutoUpdateStatisticsEnabled',
619-
'BrokerEnabled', 'CaseSensitive', 'ChangeTrackingAutoCleanUp', 'ChangeTrackingEnabled',
620-
'CloseCursorsOnCommitEnabled', 'ConcatenateNullYieldsNull', 'DatabaseOwnershipChaining',
621-
'DataRetentionEnabled', 'DateCorrelationOptimization', 'DelayedDurability', 'EncryptionEnabled',
622-
'HasDatabaseEncryptionKey', 'HasFileInCloud', 'HasMemoryOptimizedObjects', 'HonorBrokerPriority',
623-
'IsAccessible', 'IsDatabaseSnapshot', 'IsDatabaseSnapshotBase', 'IsDbAccessAdmin', 'IsDbBackupOperator',
624-
'IsDbDataReader', 'IsDbDataWriter', 'IsDbDdlAdmin', 'IsDbDenyDataReader', 'IsDbDenyDataWriter',
625-
'IsDbManager', 'IsDbOwner', 'IsDbSecurityAdmin', 'IsFabricDatabase', 'IsFullTextEnabled',
626-
'IsLedger', 'IsLoginManager', 'IsMailHost', 'IsManagementDataWarehouse', 'IsMaxSizeApplicable',
627-
'IsMirroringEnabled', 'IsParameterizationForced', 'IsReadCommittedSnapshotOn', 'IsSqlDw',
628-
'IsSqlDwEdition', 'IsSystemObject', 'IsVarDecimalStorageFormatEnabled', 'IsVarDecimalStorageFormatSupported',
629-
'LegacyCardinalityEstimation', 'LegacyCardinalityEstimationForSecondary', 'LocalCursorsDefault',
630-
'NestedTriggersEnabled', 'NumericRoundAbortEnabled', 'ParameterSniffing', 'ParameterSniffingForSecondary',
631-
'QueryOptimizerHotfixes', 'QueryOptimizerHotfixesForSecondary', 'QuotedIdentifiersEnabled', 'ReadOnly',
632-
'RecursiveTriggersEnabled', 'RemoteDataArchiveEnabled', 'RemoteDataArchiveUseFederatedServiceAccount',
633-
'TemporalHistoryRetentionEnabled', 'TransformNoiseWords', 'Trustworthy', 'WarnOnRename',
634-
'AvailabilityGroupName', 'AzureServiceObjective', 'CatalogCollation', 'Collation', 'DboLogin',
635-
'DefaultFileGroup', 'DefaultFileStreamFileGroup', 'DefaultFullTextCatalog', 'DefaultSchema',
636-
'FilestreamDirectoryName', 'MirroringPartner', 'MirroringPartnerInstance', 'MirroringWitness',
637-
'Name', 'Owner', 'PersistentVersionStoreFileGroup', 'PrimaryFilePath', 'RemoteDataArchiveCredential',
638-
'RemoteDataArchiveEndpoint', 'RemoteDataArchiveLinkedServer', 'RemoteDatabaseName', 'UserName',
639-
'ActiveConnections', 'ChangeTrackingRetentionPeriod', 'DefaultFullTextLanguage', 'DefaultLanguage',
640-
'ID', 'MaxDop', 'MaxDopForSecondary', 'MirroringRedoQueueMaxSize', 'MirroringRoleSequence',
641-
'MirroringSafetySequence', 'MirroringTimeout', 'TargetRecoveryTime', 'TwoDigitYearCutoff', 'Version',
642-
'AvailabilityDatabaseSynchronizationState', 'ChangeTrackingRetentionPeriodUnits', 'CompatibilityLevel', 'ContainmentType', 'FilestreamNonTransactedAccess', 'PageVerify', 'RecoveryModel', 'UserAccess'
643-
)
644-
645-
foreach ($parameterName in $expectedParameters)
646-
{
647-
$command.Parameters.Keys | Should -Contain $parameterName -Because "Parameter '$parameterName' should be available"
648-
}
732+
$command.Parameters.Keys | Should -Contain $ParameterName
649733
}
650734

651735
It 'Should return true when property <PropertyName> matches expected value' -ForEach $script:testCases {

0 commit comments

Comments
 (0)