Skip to content

Instantly share code, notes, and snippets.

@mallibone
Created June 7, 2017 06:39
Show Gist options
  • Save mallibone/edeb656f9081ea19b489a62c09e59206 to your computer and use it in GitHub Desktop.
Save mallibone/edeb656f9081ea19b489a62c09e59206 to your computer and use it in GitHub Desktop.
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}
$result = HasEntryInDirectory "Monday.txt" "C:\LogEntries\2017\23\"
It "Returns true" {
$result | Should Be $true
}
}
Context "If the filename does not exists in the directory" {
Mock Get-ChildItem {return @("Monday.txt", "Tuesday.txt", "Wednesday.txt")}
$result = HasEntryInDirectory "Thursday.txt" "C:\LogEntries\2017\23\"
It "Returns false" {
$result | Should Be $false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment