Created
July 30, 2021 16:21
-
-
Save bellons91/925fdec2577d2f8a95b244023235724e to your computer and use it in GitHub Desktop.
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
Mock<HttpMessageHandler> handler = new Mock<HttpMessageHandler>(); | |
var factory = handler.CreateClientFactory(); // it comes from Moq.Contrib.HttpClient | |
Mock.Get(factory).Setup(x => x.CreateClient("matrics")) | |
.Returns(() => | |
{ | |
var client = handler.CreateClient(); | |
client.BaseAddress = new Uri("https://code4it.dev"); | |
return client; | |
}); | |
handler.SetupAnyRequest().ReturnsResponse("validContent"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment