From e2af175b9f4ec771539561cc8ec9a45a3bdd2179 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 12 Mar 2018 13:57:07 +0100 Subject: [PATCH] adds tests for Test-ChallengeFile --- .../01_Test-ChallengeFile.Tests.ps1 | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/ChallengeFile/01_Test-ChallengeFile.Tests.ps1 diff --git a/tests/ChallengeFile/01_Test-ChallengeFile.Tests.ps1 b/tests/ChallengeFile/01_Test-ChallengeFile.Tests.ps1 new file mode 100644 index 0000000..f5318cd --- /dev/null +++ b/tests/ChallengeFile/01_Test-ChallengeFile.Tests.ps1 @@ -0,0 +1,39 @@ +#region HEADER +$RepoRoot = (Get-GitDirectory).replace('\.git', '') +$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' +$sut = $sut -replace "\d{2}`_", '' +$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName +# Skip try loading the source file if it doesn't exists. +If ($suthome.Length -gt 0) { + . $suthome +} +Else { + Write-Warning ("Could not find source file {0}" -f $sut) +} + +# load additional functions defined in the repository. Replace the expression . +. (Get-ChildItem -Path $RepoRoot -Filter "Test-ChallengeFile.ps1" -Recurse).FullName + +#endregion HEADER + +Describe "Test-ChallengeFile" { + Context "Basic input tests" { + Mock Test-Path {return $true} + It "No parameter with existing challenge file" { + {Test-ChallengeFile} | Should -Not -Throw + } + It "No parameter and existing file should return true" { + Test-ChallengeFile | Should -Be $true + } + Context "Execute with parameter" { + $TestChFile = "{0}\resources\Challenge.bin" -f $RepoRoot + It "Provide valid path" { + Test-ChallengeFile -Path $TestChFile | Should -Be $true + } + It "Provide fake path" { + Test-ChallengeFile -Path "C:\notexisting.bin" | Should -Be $false + } + } + + } +}