Guest User

Untitled

a guest
Jan 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. function dummy {
  2. return Get-Date -f "dd"
  3. }
  4.  
  5. $here = Split-Path -Parent $MyInvocation.MyCommand.Path
  6. $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '.Tests.', '.'
  7. . "$here$sut"
  8.  
  9. Describe "dummy" {
  10. Mock Get-Date { return "01" } -Verifiable -ParameterFilter {$f -match "dd"}
  11.  
  12. It "does something useful" {
  13. dummy
  14.  
  15. Assert-VerifiableMocks
  16. }
  17. }
  18.  
  19. Describing dummy
  20. [-] does something useful 99ms
  21. RuntimeException: Expected Get-Date to be called with $f -match "dd"
  22. at Assert-VerifiableMocks, C:Program FilesWindowsPowerShellModulesPester3.4.0FunctionsMock.ps1: line 434
  23. at <ScriptBlock>, E:…dummy.Tests.ps1: line 11
  24. Tests completed in 99ms
  25. Passed: 0 Failed: 1 Skipped: 0 Pending: 0 Inconclusive: 0
  26.  
  27. Name Value
  28. ---- -----
  29. PSVersion 5.1.14393.1198
  30. PSEdition Desktop
  31. PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
  32. BuildVersion 10.0.14393.1198
  33. CLRVersion 4.0.30319.42000
  34. WSManStackVersion 3.0
  35. PSRemotingProtocolVersion 2.3
  36. SerializationVersion 1.1.0.1
  37.  
  38. Mock Get-Date { return "01" } -Verifiable -ParameterFilter {$format -match "dd"}
  39.  
  40. Describing dummy
  41. [+] does something useful 31ms
Add Comment
Please, Sign In to add comment