Skip to content

Commit 016f4c3

Browse files
committed
fixed formatting bug with CompressionRatio
1 parent 3b2bbbe commit 016f4c3

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

module/PSCompression.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'bin/netstandard2.0/PSCompression.dll'
1212

1313
# Version number of this module.
14-
ModuleVersion = '2.0.4'
14+
ModuleVersion = '2.0.5'
1515

1616
# Supported PSEditions
1717
# CompatiblePSEditions = @()

src/PSCompression/ZipEntryFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static string GetRatio(long size, long compressedSize)
2525

2626
if (float.IsNaN(compressedRatio))
2727
{
28-
return "0.00%";
28+
compressedRatio = 0;
2929
}
3030

3131
return string.Format("{0:F2}%", 100 - (compressedRatio * 100));

tests/ZipEntryBase.tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Describe 'ZipEntryBase Class' {
4747
}
4848

4949
It 'Has a CompressionRatio Property' {
50+
New-ZipEntry $zip.FullName -EntryPath empty.txt
5051
($zip | Get-ZipEntry).CompressionRatio | Should -BeOfType ([string])
5152
}
5253

tests/ZipEntryCmdlets.tests.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ Describe 'ZipEntry Cmdlets' {
157157
}
158158

159159
Context 'Remove-ZipEntry' -Tag 'Remove-ZipEntry' {
160+
It 'No entry is removed with -WhatIf' {
161+
$zip | Get-ZipEntry | Remove-ZipEntry -WhatIf
162+
$zip | Get-ZipEntry | Should -Not -BeNullOrEmpty
163+
}
164+
160165
It 'Can remove file entries' {
161166
{ $zip | Get-ZipEntry -Type Archive | Remove-ZipEntry } |
162167
Should -Not -Throw
@@ -238,13 +243,21 @@ Describe 'ZipEntry Cmdlets' {
238243
$structure, $content | Out-Null
239244
}
240245

246+
It 'No entry is renamed with -WhatIf' {
247+
$zip | Get-ZipEntry |
248+
Rename-ZipEntry -NewName { 'test' + $_.Name } -WhatIf
249+
250+
$zip | Get-ZipEntry |
251+
Should -Not -Match '^testtest'
252+
}
253+
241254
It 'Can rename file entries using a delay-bind ScriptBlock' {
242255
{ $zip | Get-ZipEntry -Type Archive | Rename-ZipEntry -NewName { 'test' + $_.Name } } |
243256
Should -Not -Throw
244257

245258
$zip | Get-ZipEntry -Type Archive |
246259
ForEach-Object Name |
247-
Should -Match '^test'
260+
Should -Match '^testtest'
248261
}
249262

250263
It 'Produces output with -PassThru' {

0 commit comments

Comments
 (0)