/
Invoke-NUnitTestsForAllProjects.Tests.ps1
74 lines (58 loc) · 1.54 KB
/
Invoke-NUnitTestsForAllProjects.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".").Replace(".ps1","")
$baseModulePath = "$here\..\tools\powershell\modules"
$module = Get-Module $sut
if ($module -ne $null)
{
Remove-Module $sut
}
Describe "Invoke-NUnitTestsForAllProjects" {
Context "When there are NO test assemblies" {
Import-Module "$baseModulePath\$sut"
$searchString = "test"
Mock -ModuleName $sut Write-Warning {} -Verifiable -ParameterFilter {
$Message -eq "No assemblies found matching the test naming convention ($searchString), exiting without executing tests."
}
$result = 0
try {
$result = Invoke-NUnitTestsForAllProjects -searchString $searchString
}
catch {
throw
}
finally {
Remove-Module $sut
}
It "Writes a descriptive warning" {
Assert-VerifiableMocks
}
It "Exits module with code 0" {
$result | Should Be 0
}
}
#}
#Describe "Invoke-NUnitTestsForAllProjects" {
Context "When module is invoked with a path that does NOT exist" {
Import-Module "$baseModulePath\$sut"
Mock -ModuleName $sut Confirm-Path { return 1 }
$testBasePath = "$TestDrive\NonExistentPath\"
$result = ""
try {
$result = Invoke-NUnitTestsForAllProjects -path $testBasePath
}
catch {
throw
}
finally {
Remove-Module $sut
}
It "Should exit the module with code 1" {
$result | Should Be 1
}
}
}
$module = Get-Module $sut
if ($module -ne $null)
{
Remove-Module $sut
}