Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 15dc749

Browse files
committed
add tests
1 parent a0976ec commit 15dc749

File tree

4 files changed

+93
-36
lines changed

4 files changed

+93
-36
lines changed

build.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## Copyright (c) Microsoft Corporation.
32
## Licensed under the MIT License.
43

test/Base64.tests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Copyright (c) Microsoft Corporation.
2+
## Licensed under the MIT License.
3+
4+
Describe 'Base64 cmdlet tests' {
5+
BeforeAll {
6+
$testString = 'Hello World!'
7+
$testBase64 = 'SGVsbG8gV29ybGQh'
8+
}
9+
10+
It 'ConvertTo-Base64 will accept text input from parameter' {
11+
ConvertTo-Base64 -Text $testString | Should -BeExactly $testBase64
12+
}
13+
14+
It 'ConvertTo-Base64 will accept text input from positional parameter' {
15+
ConvertTo-Base64 $testString | Should -BeExactly $testBase64
16+
}
17+
18+
It 'ConvertTo-Base64 will accept text input from pipeline' {
19+
$testString | ConvertTo-Base64 | Should -BeExactly $testBase64
20+
}
21+
22+
It 'ConvertFrom-Base64 will accept encoded input from parameter' {
23+
ConvertFrom-Base64 -EncodedText $testBase64 | Should -BeExactly $testString
24+
}
25+
26+
It 'ConvertFrom-Base64 will accept encoded input from positional parameter' {
27+
ConvertFrom-Base64 $testBase64 | Should -BeExactly $testString
28+
}
29+
30+
It 'ConvertFrom-Base64 will accept encoded input form pipeline' {
31+
$testBase64 | ConvertFrom-Base64 | Should -BeExactly $testString
32+
}
33+
}

test/CompareText.tests.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Copyright (c) Microsoft Corporation.
2+
## Licensed under the MIT License.
3+
4+
Describe 'Compare-Test tests' {
5+
BeforeAll {
6+
$leftText = @"
7+
This is some
8+
example text.
9+
"@
10+
$rightText = @"
11+
This is other
12+
example text used!
13+
"@
14+
15+
$expectedInline = @"
16+
17+
 This is someother
18+
example text. used!
19+
20+
21+
"@
22+
23+
$expectedSideBySide = @"
24+
25+
1 | This is some  |  This is other…
26+
2 | example text. | example text…
27+

28+
29+
30+
"@
31+
32+
}
33+
34+
It 'Compare with no specified view uses inline' {
35+
$out = Compare-Text -LeftText $leftText -RightText $rightText | Out-String
36+
$out | Should -BeExactly $expectedInline
37+
}
38+
39+
It 'Compare with no specified view uses inline and positional parameters' {
40+
$out = Compare-Text $leftText $rightText | Out-String
41+
$out | Should -BeExactly $expectedInline
42+
}
43+
44+
It 'Compare with inline works' {
45+
$out = Compare-Text $leftText $rightText -View Inline | Out-String
46+
$out | Should -BeExactly $expectedInline
47+
}
48+
49+
It 'Compare with sideybyside works' {
50+
$out = Compare-Text $leftText $rightText -View SideBySide | Out-String
51+
$out | Should -BeExactly $expectedSideBySide
52+
}
53+
}

yaml/template/runtest.yml

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,13 @@ parameters:
44
jobDisplayName: 'Run test'
55

66
jobs:
7-
- job: '${{ parameters.jobName }}_net461'
8-
pool:
9-
vmImage: ${{ parameters.vmImageName }}
10-
displayName: ${{ parameters.jobDisplayName }} - net461
11-
condition: startsWith('${{ parameters.vmImageName }}', 'win')
12-
steps:
13-
- download: current
14-
- task: DotNetCoreCLI@2
15-
displayName: Tests on Windows - net461
16-
inputs:
17-
command: test
18-
projects: test/test.csproj
19-
nobuild: true
20-
arguments: --runtime net461 --collect:"XPlat Code Coverage"
21-
testRunTitle: Tests on Windows - net461
22-
- task: PublishCodeCoverageResults@1
23-
inputs:
24-
codeCoverageTool: cobertura
25-
summaryFileLocation: $(Agent.TempDirectory)/**/coverage.cobertura.xml
26-
27-
- job: '${{ parameters.jobName }}_netcoreapp31'
7+
- job: '${{ parameters.jobName }}_netstandard20'
288
pool:
299
vmImage: ${{ parameters.vmImageName }}
30-
displayName: ${{ parameters.jobDisplayName }} - netcoreapp3.1
10+
displayName: ${{ parameters.jobDisplayName }} - netstandard2.0
3111
steps:
32-
- download: current
33-
- task: DotNetCoreCLI@2
34-
displayName: Tests on ${{parameters.vmImageName}} - netcoreapp3.1
35-
inputs:
36-
command: test
37-
projects: test/test.csproj
38-
nobuild: true
39-
arguments: --runtime netcoreapp3.1 --collect:"XPlat Code Coverage"
40-
testRunTitle: Tests on ${{parameters.vmImageName}}
41-
- task: PublishCodeCoverageResults@1
42-
inputs:
43-
codeCoverageTool: cobertura
44-
summaryFileLocation: $(Agent.TempDirectory)/**/coverage.cobertura.xml
12+
- pwsh: |
13+
Import-Module ./out/Microsoft.PowerShell.TextUtility.psd1
14+
Invoke-Pester -Path ./test
15+
displayName: Test
16+
condition: succeeded()

0 commit comments

Comments
 (0)