Skip to content

Instantly share code, notes, and snippets.

@abrugsch
Created August 9, 2023 15:15
Show Gist options
  • Save abrugsch/d0bc8e73743f3a44e1026c67ade2ac2c to your computer and use it in GitHub Desktop.
Save abrugsch/d0bc8e73743f3a44e1026c67ade2ac2c to your computer and use it in GitHub Desktop.
remove moq
replaces about 75% of moq calls with NSubstitute equivalents (taken from the moq issue thread discussing open source funding)
Replace "using Moq;" with "using NSubstitute;" (non-regex)
Replace "new Mock<(.*?)>()" with "Substitute.For<$1>()" (Regex)
Replace "Mock<(.*?)>" with "$1" (Regex)
Replace ".Setup(x => x." with "." (non-regex)
Replace ").ReturnsAsync(" with ".Returns(" (non-regex)
Replace "It.IsAny<" with "Arg.Any<" (non-regex)
Replace "It.IsAny<" with "Arg.Any<" (non-regex)
Replace "(\w+.)Verify(x => x.(\w+)((.*?)), Times.Once())" with "await $1Received(1).$2($3)" (Regex)
Replace "(\w+.)Verify(x => x.(\w+)((.*?)), Times.Never())" With "await $1Received(0).$2($3)" (Regex)
Replace ".Object," with "," (non-regex)
Replace ".Object);" with ");" (non-regex)
@abrugsch
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment