Skip to content

Commit daebf52

Browse files
committed
Enhance BackupFileSpec tests: Validate instantiation and type correctness
1 parent cd446df commit daebf52

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tests/Unit/Classes/BackupFileSpec.Tests.ps1

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,27 @@ AfterAll {
4848

4949
Describe 'BackupFileSpec' -Tag 'BackupFileSpec' {
5050
Context 'When instantiating the class' {
51-
It 'Should not throw when instantiated with default constructor' {
52-
InModuleScope -ScriptBlock {
53-
{ [BackupFileSpec]::new() } | Should -Not -Throw
51+
It 'Should be able to instantiate with default constructor' {
52+
$script:mockBackupFileSpecInstance = InModuleScope -ScriptBlock {
53+
[BackupFileSpec]::new()
5454
}
5555
}
5656

57-
It 'Should not throw when instantiated with all parameters' {
58-
InModuleScope -ScriptBlock {
59-
{ [BackupFileSpec]::new('MyDatabase', 'C:\Data\MyDatabase.mdf', 'D', 'PRIMARY', 10485760, 1073741824) } | Should -Not -Throw
57+
It 'Should be of the correct type' {
58+
$mockBackupFileSpecInstance | Should -Not -BeNullOrEmpty
59+
$mockBackupFileSpecInstance.GetType().Name | Should -Be 'BackupFileSpec'
60+
}
61+
62+
It 'Should be able to instantiate with all parameters' {
63+
$script:mockBackupFileSpecInstanceWithParams = InModuleScope -ScriptBlock {
64+
[BackupFileSpec]::new('MyDatabase', 'C:\Data\MyDatabase.mdf', 'D', 'PRIMARY', 10485760, 1073741824)
6065
}
6166
}
67+
68+
It 'Should be of the correct type when instantiated with parameters' {
69+
$mockBackupFileSpecInstanceWithParams | Should -Not -BeNullOrEmpty
70+
$mockBackupFileSpecInstanceWithParams.GetType().Name | Should -Be 'BackupFileSpec'
71+
}
6272
}
6373

6474
Context 'When setting properties using the parameterized constructor' {

0 commit comments

Comments
 (0)