Skip to content

Instantly share code, notes, and snippets.

@tdewilde
Last active December 17, 2015 20:48
Show Gist options
  • Select an option

  • Save tdewilde/5669792 to your computer and use it in GitHub Desktop.

Select an option

Save tdewilde/5669792 to your computer and use it in GitHub Desktop.
Extension method to convert an integer to a Guid. Useful for mocking objects in a unit test.
public static Guid ToGuid(this int value)
{
byte[] bytes = new byte[16];
BitConverter.GetBytes(value).CopyTo(bytes, 0);
return new Guid(bytes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment