Skip to content

Commit 33f7d65

Browse files
committed
Update the tests
1 parent 4224d04 commit 33f7d65

10 files changed

Lines changed: 32 additions & 32 deletions

Tests/Command/New-CommandBuilder.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Describe "New-CommandBuilder" {
3838

3939
It "should also return an empty parameter collection" {
4040
$command = (New-SqlCommandBuilder $connection).GetDeleteAllCommand([Character])
41-
$command.Item2 | Should -BeNullOrEmpty
41+
Should-Be 0 $command.Item2.Count
4242
}
4343
}
4444

@@ -92,7 +92,7 @@ Describe "New-CommandBuilder" {
9292

9393
It "should also return an empty parameter collection" {
9494
$command = (New-SqlCommandBuilder $connection).GetFindAllCommand([Character])
95-
$command.Item2 | Should -BeNullOrEmpty
95+
Should-Be 0 $command.Item2.Count
9696
}
9797

9898
It "should allow sorting the results by a specific set of columns" {

Tests/Command/New-OrderHintCollection.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ using namespace System.Collections.Generic
88
Describe "New-OrderHintCollection" {
99
It "should create an empty collection by default" {
1010
$collection = New-SqlOrderHintCollection
11-
$collection | Should -BeNullOrEmpty
11+
Should-Be 0 $collection.Count
1212
}
1313

1414
It "should create a collection from a single order hint" {
1515
$collection = New-SqlOrderHintCollection (New-SqlOrderHint ID Descending)
1616
Should-Be 1 $collection.Count
1717

1818
$orderHint = $collection[0]
19-
$orderHint.Column | Should -BeExactly ID
19+
Should-BeString ID $orderHint.Column -CaseSensitive
2020
Should-Be ([SortOrder]::Descending) $orderHint.SortOrder
2121
}
2222

@@ -26,7 +26,7 @@ Describe "New-OrderHintCollection" {
2626
Should-Be 2 $collection.Count
2727

2828
$orderHint = $collection[$collection.Count - 1]
29-
$orderHint.Column | Should -BeExactly Name
29+
Should-BeString Name $orderHint.Column -CaseSensitive
3030
Should-Be ([SortOrder]::Ascending) $orderHint.SortOrder
3131
}
3232

@@ -67,14 +67,14 @@ Describe "New-OrderHintCollection" {
6767
It "should return the order hint with the specified column name" {
6868
$collection = New-SqlOrderHintCollection (New-SqlOrderHint ID Descending), (New-SqlOrderHint Name)
6969
$orderHint = $collection["id"]
70-
$orderHint.Column | Should -BeExactly ID
70+
Should-BeString ID $orderHint.Column -CaseSensitive
7171
Should-Be ([SortOrder]::Descending) $orderHint.SortOrder
7272
Should-Be $orderHint $collection[0]
7373
}
7474

7575
It "should return `$null, or throw an error, if the specified column name does not exist" {
7676
$collection = New-SqlOrderHintCollection (New-SqlOrderHint ID Descending), (New-SqlOrderHint Name)
77-
$collection["foo"] | Should -BeNullOrEmpty
77+
Should-BeNull $collection["foo"]
7878

7979
Set-StrictMode -Version Latest
8080
Should-Throw -ScriptBlock { $collection["foo"] }
@@ -102,7 +102,7 @@ Describe "New-OrderHintCollection" {
102102
$collection.RemoveAt("name")
103103
Should-Be 1 $collection.Count
104104
$collection.RemoveAt("id")
105-
$collection | Should -BeNullOrEmpty
105+
Should-Be 0 $collection.Count
106106
}
107107

108108
It "should throw an error if the specified column name does not exist" {

Tests/Command/New-ParameterCollection.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using module ../../Sql.psd1
1010
Describe "New-ParameterCollection" {
1111
It "should create an empty collection by default" {
1212
$collection = New-SqlParameterCollection
13-
$collection | Should -BeNullOrEmpty
13+
Should-Be 0 $collection.Count
1414
}
1515

1616
It "should create a collection from a single parameter" {
@@ -37,7 +37,7 @@ Describe "New-ParameterCollection" {
3737
Context "AddWithValue" {
3838
It "should add a new parameter to the collection" {
3939
$collection = New-SqlParameterCollection
40-
$collection | Should -BeNullOrEmpty
40+
Should-Be 0 $collection.Count
4141

4242
$parameter = $collection.AddWithValue("Name", "Value1")
4343
Should-Be 1 $collection.Count
@@ -80,8 +80,8 @@ Describe "New-ParameterCollection" {
8080

8181
It "should create a collection from the specified hash table of named parameters" {
8282
[SqlParameterCollection] $collection = @{ foo = "bar"; baz = "qux" }
83-
Compare-Object @("@foo", "@baz") $collection.PSForEach{ $_.Name } | Should -BeNullOrEmpty
84-
Compare-Object @("bar", "qux") $collection.PSForEach{ $_.Value } | Should -BeNullOrEmpty
83+
Should-BeNull (Compare-Object @("@foo", "@baz") $collection.PSForEach{ $_.Name })
84+
Should-BeNull (Compare-Object @("bar", "qux") $collection.PSForEach{ $_.Value })
8585
}
8686
}
8787

@@ -96,7 +96,7 @@ Describe "New-ParameterCollection" {
9696

9797
It "should return `$null, or throw an error, if the specified name does not exist" {
9898
$collection = New-SqlParameterCollection (New-SqlParameter "?1" 123), (New-SqlParameter "@Key" Unique -DbType AnsiString)
99-
$collection["@Foo"] | Should -BeNullOrEmpty
99+
Should-BeNull $collection["@Foo"]
100100

101101
Set-StrictMode -Version Latest
102102
Should-Throw -ScriptBlock { $collection["@Foo"] }
@@ -125,7 +125,7 @@ Describe "New-ParameterCollection" {
125125
$collection.RemoveAt("Key")
126126
Should-Be 1 $collection.Count
127127
$collection.RemoveAt("?1")
128-
$collection | Should -BeNullOrEmpty
128+
Should-Be 0 $collection.Count
129129
}
130130

131131
It "should throw an error if the specified name does not exist" {

Tests/Connection/New-Connection.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Describe "New-Connection" {
1212
@{ Provider = "SqlClient"; ConnectionString = "Server=localhost; Database=TestDb; Uid=user; Pwd=password"; Expected = [System.Data.SqlClient.SqlConnection] }
1313
) {
1414
$connection = New-SqlConnection $provider $connectionString
15-
$connection | Should -BeOfType $expected
15+
Should-HaveType $expected $connection
1616
Should-Be ([ConnectionState]::Closed) $connection.State
1717
}
1818

Tests/Mapping/DbTableInfo.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using module ../Character.psm1
99
Describe "DbTableInfo" {
1010
Context "Columns" {
1111
It "should return all columns associated with the specified entity class" {
12-
[DbTableInfo]::new([ConsoleKeyInfo]).Columns.Keys | Should -BeNullOrEmpty
12+
Should-Be 0 ([DbTableInfo]::new([ConsoleKeyInfo]).Columns.Count)
1313

1414
$columns = [DbTableInfo]::new([Character]).Columns
1515
Should-Be 5 $columns.Count
@@ -19,10 +19,10 @@ Describe "DbTableInfo" {
1919

2020
Context "IdentityColumn" {
2121
It "should return the identity column associated with the specified entity class, if any" {
22-
[DbTableInfo]::new([ConsoleKeyInfo]).IdentityColumn | Should -BeNullOrEmpty
22+
Should-BeNull ([DbTableInfo]::new([ConsoleKeyInfo]).IdentityColumn)
2323

2424
$identityColumn = [DbTableInfo]::new([Character]).IdentityColumn
25-
$identityColumn | Should -Not -BeNullOrEmpty
25+
Should-NotBeNull $identityColumn
2626
$identityColumn.Name | Should -BeExactly ID
2727
}
2828
}
@@ -39,7 +39,7 @@ Describe "DbTableInfo" {
3939

4040
Context "Schema" {
4141
It "should return `$null` when there is no [Table] attribute" {
42-
[DbTableInfo]::new([ConsoleKeyInfo]).Schema | Should -BeNullOrEmpty
42+
Should-BeNull ([DbTableInfo]::new([ConsoleKeyInfo]).Schema)
4343
}
4444

4545
It "should return the value of the [Table] attribute when it is present" {

Tests/Mapping/Get-Mapper.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ Describe "Get-Mapper" {
9090
It "should support creating an object of type [psobject]" {
9191
$properties = @{ CLASS = "Bard/minstrel"; firstName = "Cédric"; gender = "Balrog"; lastName = $null }
9292
$psObject = (Get-SqlMapper).CreateInstance([psobject], $properties)
93-
$psObject | Should -BeOfType ([psobject])
93+
Should-HaveType ([psobject]) $psObject
9494
$psObject.CLASS | Should -BeExactly "Bard/minstrel"
9595
$psObject.firstName | Should -BeExactly Cédric
9696
$psObject.gender | Should -BeExactly ([CharacterGender]::Balrog.ToString())
97-
$psObject.lastName | Should -BeNullOrEmpty
97+
Should-BeNull $psObject.lastName
9898
}
9999

100100
It "should create an object of the specified type" {
101101
$properties = @{ CLASS = "Bard/minstrel"; firstName = "Cédric"; gender = "Balrog"; lastName = $null }
102102
$character = (Get-SqlMapper).CreateInstance([Character], $properties)
103-
$character | Should -BeOfType ([Character])
103+
Should-HaveType ([Character]) $character
104104
$character.FirstName | Should -BeExactly Cédric
105105
Should-Be ([CharacterGender]::Balrog) $character.Gender
106106
Should-BeEmptyString $character.LastName

Tests/Object/Find-Object.Tests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,38 @@ Describe "Find-Object" {
3232
$records = Find-SqlObject $connection -All -Class ([Character]) -Columns gender
3333
Should-Be 1 $records[0].Id
3434
Should-Be ([CharacterGender]::Human) $records[0].Gender
35-
$records[0].FullName | Should -BeNullOrEmpty
35+
Should-BeEmptyString $records[0].FullName
3636
Should-Be 16 $records[15].Id
3737
Should-Be ([CharacterGender]::DarkLord) $records[15].Gender
38-
$records[15].FullName | Should -BeNullOrEmpty
38+
Should-BeEmptyString $records[15].FullName
3939
}
4040
}
4141

4242
Context "Id" {
4343
It "should find the entity with the specified identifier" {
4444
$record = Find-SqlObject $connection -Class ([Character]) -Id 2
45-
$record | Should -Not -BeNullOrEmpty
45+
Should-NotBeNull $record
4646
Should-Be 2 $record.Id
4747
$record.FullName | Should -BeExactly Balin
4848

4949
$record = Find-SqlObject $connection -Class ([Character]) -Id 14
50-
$record | Should -Not -BeNullOrEmpty
50+
Should-NotBeNull $record
5151
Should-Be 14 $record.Id
5252
$record.FullName | Should -BeExactly "Sam Gamgee"
5353
}
5454

5555
It "should allow selecting a specific set of columns" {
5656
$record = Find-SqlObject $connection -Class ([Character]) -Id 2 -Columns gender
57-
$record.FullName | Should -BeNullOrEmpty
57+
Should-BeEmptyString $record.FullName
5858
Should-Be ([CharacterGender]::Dwarf) $record.Gender
5959

6060
$record = Find-SqlObject $connection -Class ([Character]) -Id 14 -Columns gender
61-
$record.FullName | Should -BeNullOrEmpty
61+
Should-BeEmptyString $record.FullName
6262
Should-Be ([CharacterGender]::Hobbit) $record.Gender
6363
}
6464

6565
It "should return `$null if the entity is not found" {
66-
Find-SqlObject $connection -Class ([Character]) -Id 666 | Should -BeNullOrEmpty
66+
Should-BeNull (Find-SqlObject $connection -Class ([Character]) -Id 666)
6767
}
6868
}
6969
}

Tests/Object/Publish-Object.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Describe "Publish-Object" {
1818
Should-BeEmptyString $record.FullName
1919

2020
$id = Publish-SqlObject $connection -InputObject $record
21-
$id | Should -BeGreaterThan 16
21+
Should-BeGreaterThan 16 $id
2222
Should-Be $id $record.Id
2323

2424
$records = Invoke-SqlQuery $connection -As ([Character]) -Command $sql

Tests/Object/Remove-Object.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Describe "Remove-Object" {
1212
Context "All" {
1313
It "should remove all entities from the underlying table" {
1414
$sql = "SELECT COUNT(*) FROM Characters"
15-
Get-SqlScalar $connection -As ([int]) -Command $sql | Should -BeGreaterThan 0
15+
Should-BeGreaterThan 0 (Get-SqlScalar $connection -As ([int]) -Command $sql)
1616
Remove-SqlObject $connection -Class ([Character]) -All -Truncate
1717
Should-Be 0 (Get-SqlScalar $connection -As ([int]) -Command $sql)
1818
}

Tests/Query/Get-Scalar.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Describe "Get-Scalar" {
1313
Should-Be 2 (Get-SqlScalar $connection -As ([int]) -Command $sql -Parameters @{ Gender = "Balrog" })
1414

1515
$sql = "SELECT tbl_name FROM sqlite_schema WHERE type = @Type AND name = @Name"
16-
Get-SqlScalar $connection -As ([string]) -Command $sql -Parameters @{ Name = "Characters"; Type = "table" } | Should -BeExactly Characters
16+
Should-BeString Characters (Get-SqlScalar $connection -As ([string]) -Command $sql -Parameters @{ Name = "Characters"; Type = "table" }) -CaseSensitive
1717

1818
$sql = "SELECT tbl_name FROM sqlite_schema WHERE name = @Name"
1919
Should-BeNull (Get-SqlScalar $connection -As ([string]) -Command $sql -Parameters @{ Name = "FooBarBazQux" })

0 commit comments

Comments
 (0)