8000 Fix internal color converter and tests · PoshCode/PSGit@64645a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 64645a8

Browse files
committed
Fix internal color converter and tests
1 parent 8a2434a commit 64645a8

File tree

3 files changed

+488
-485
lines changed

3 files changed

+488
-485
lines changed

Tests/Internal.Steps.ps1

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
1-
<#
2-
When "WriteMessage ((?<type>\S+)\s+(?<message>\S+))? ?is called" {
3-
param($type,$message)
4-
Mock Write-Host -ParameterFilter {$object -eq "TIP: test"} -Verifiable
5-
6-
if($type) {
7-
$script:result = &(gmo psgit){WriteMessage -type test -message $message -InformationVariable information -InformationAction SilentlyContinue;$information }
8-
} else {
9-
$script:result = &(gmo psgit){WriteMessage -type Tip -message test SilentlyContinue; $information }
10-
}
11-
}
12-
#>
13-
Given "we have WPF loaded" {
14-
Add-Type -AssemblyName presentationCore
15-
}
16-
When "WriteMessage ((?<type>\S+)\s+(?<message>\S+)) is called" {
17-
param($type,$message)
18-
19-
Mock Write-Host {"$($type.toupper()): $message"} -Verifiable -ModuleName psgit
20-
$script:result = &(gmo psgit){WriteMessage -type $args[0] -message $args[1]} $type $message
21-
}
22-
23-
When 'ConvertColor (?<color>\S+)? ?is called' {
24-
param($color)
25-
#$script:errors = $null
26-
try {
27-
$script:result = &(gmo psgit){ConvertColor -color $args[0] } "$color"
28-
}
29-
catch {
30-
$script:errors = $_
31-
}
32-
33-
}
34-
35-
When 'ConvertColor is called with Default set to red' {
36-
$script:result = &(gmo psgit){ConvertColor -default "red" }
37-
}
38-
39-
Then "it will Throw a Terminating Error" {
40-
41-
if(! $script:errors)
42-
{
43-
return "No error found"
44-
}
45-
}
1+
<#
2+
When "WriteMessage ((?<type>\S+)\s+(?<message>\S+))? ?is called" {
3+
param($type,$message)
4+
Mock Write-Host -ParameterFilter {$object -eq "TIP: test"} -Verifiable
5+
6+
if($type) {
7+
$script:result = &(gmo psgit){WriteMessage -type test -message $message -InformationVariable information -InformationAction SilentlyContinue;$information }
8+
} else {
9+
$script:result = &(gmo psgit){WriteMessage -type Tip -message test SilentlyContinue; $information }
10+
}
11+
}
12+
#>
13+
Given "we have WPF loaded" {
14+
Add-Type -AssemblyName presentationCore
15+
}
16+
When "WriteMessage ((?<type>\S+)\s+(?<message>\S+)) is called" {
17+
param($type,$message)
18+
19+
Mock Write-Host {"$($type.toupper()): $message"} -Verifiable -ModuleName psgit
20+
$script:result = &(gmo psgit){WriteMessage -type $args[0] -message $args[1]} $type $message
21+
}
22+
23+
When 'ConvertColor (?<color>\S+)? ?is called' {
24+
param($color)
25+
$script:exceptions = $null
26+
try {
27+
$script:result = &(gmo psgit){ConvertColor -color $args[0] } "$color"
28+
}
29+
catch {
30+
$script:exceptions = $_
31+
}
32+
33+
}
34+
35+
When 'ConvertColor is called with Default set to red' {
36+
$script:result = &(gmo psgit){ConvertColor -default "red" }
37+
}
38+
39+
Then "it will Throw a Terminating Error" {
40+
if($script:result -or !$script:exceptions)
41+
{
42+
throw "No error found"
43+
}
44+
}

Tests/Internal.feature

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
Feature: Internal Function Tests
2-
This will test the functionality of internal functions
3-
4-
Scenario: Simple Message output with basic params
5-
Given we are NOT in a repository
6-
When WriteMessage test info is called
7-
Then the output should be: "TEST: info"
8-
9-
Scenario: Simple Color convert
10-
Given we are NOT in a repository
11-
When ConvertColor blue is called
12-
Then the output should be: "Blue"
13-
14-
Scenario: no WPF support
15-
When ConvertColor #00aaaaaa is called
16-
Then it will Throw a Terminating Error
17-
18-
Scenario: Color convert in ISE
19-
Given we have WPF loaded
20-
When ConvertColor #ffffff is called
21-
Then the output should be: "White"
22-
23-
Scenario: Color convert in ISE (mostly for codecov on if's)
24-
Given we have WPF loaded
25-
When ConvertColor #00123123 is called
26-
Then the output should be: "Black"
27-
28-
Scenario: Color Convert Transparent background
29-
Given we have WPF loaded
30-
When ConvertColor #00FFFFFF is called
31-
Then the output should be: "Black"
32-
33-
Scenario: Color Convert Default param test
34-
When ConvertColor is called with Default set to red
35-
Then the output should be: "Red"
36-
37-
Scenario: Color Convertwith no param
38-
When ConvertColor is called
1+
Feature: Internal Function Tests
2+
This will test the functionality of internal functions
3+
4+
Scenario: Simple Message output with basic params
5+
Given we are NOT in a repository
6+
When WriteMessage test info is called
7+
Then the output should be: "TEST: info"
8+
9+
Scenario: Simple Color convert
10+
Given we are NOT in a repository
11+
When ConvertColor blue is called
12+
Then the output should be: "Blue"
13+
14+
Scenario: no WPF support
15+
When ConvertColor #00aaaaaa is called
16+
Then the output should be: "Black"
17+
18+
Scenario: Color convert in ISE
19+
Given we have WPF loaded
20+
When ConvertColor #ffffff is called
21+
Then the output should be: "White"
22+
23+
Scenario: Color convert in ISE (mostly for codecov on if's)
24+
Given we have WPF loaded
25+
When ConvertColor #00123123 is called
26+
Then the output should be: "Black"
27+
28+
Scenario: Color Convert Transparent background
29+
Given we have WPF loaded
30+
When ConvertColor #00FFFFFF is called
31+
Then the output should be: "Black"
32+
33+
Scenario: Color Convert Default param test
34+
When ConvertColor is called with Default set to red
35+
Then the output should be: "Red"
36+
37+
Scenario: Color Convertwith no param
38+
When ConvertColor is called
3939
Then the output should be: "Yellow"

0 commit comments

Comments
 (0)
0