Skip to content

Instantly share code, notes, and snippets.

@ifew
Last active July 8, 2018 16:15
Show Gist options
  • Save ifew/d97756b4bd402230bb8b79f883b41963 to your computer and use it in GitHub Desktop.
Save ifew/d97756b4bd402230bb8b79f883b41963 to your computer and use it in GitHub Desktop.
.Net Core Mock Test with Moq4
public void When_Member_Access_to_Profile_By_Using_Moq() {
var mock = new Mock<IAuthorize>();
mock.Setup(auth => auth.CheckAuthorize(It.IsAny<string>(), It.IsAny<string>())).Returns(true).Verifiable();
Member member = new Member(mock.Object);
mock.Verify(auth => auth.CheckAuthorize(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment