Created
May 20, 2016 13:25
-
-
Save nohwnd/c8e72858905c70f2558bfb1eefb403a9 to your computer and use it in GitHub Desktop.
Faking call to external static method in Pester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add-type -TypeDefinition @" | |
using System; | |
public static class KeyboardEventTestUtil { | |
public static string keybd_event(byte bVk, byte bScan, UInt32 dwFlags, System.UIntPtr dwExtraInfo) { | |
return string.Format("{0}:{1}:{2}:{3}", bVk,bScan,dwFlags,dwExtraInfo); | |
} | |
} | |
"@ | |
describe "t" { | |
it "b" { | |
[KeyboardEventTestUtil]::keybd_event(1,1,1,[UIntPtr]::Zero) | should be "1:1:1:0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can get the signature of the method by importing it from the user32.dll and calling it without () and then modifying it a bit to make it compatible with C#. Also the original is
void
our method returns string, so we can assert.Linkback: https://twitter.com/Bjompen/status/733638792347717636