geschrieben.
Code: Select all
var mockHandler = new Mock(MockBehavior.Strict);
mockHandler
.Protected()
.Setup(
"SendAsync",
ItExpr.Is(m => m.Method == HttpMethod.Get),
ItExpr.IsAny())
.ReturnsAsync(mockResponse);
< /code>
Dann mache ich den Anruf zum API -Dienst und möchte die Rückgabe überprüfen. < /p>
mockHandler.Protected().Verify(
"SendAsync",
Times.Exactly(1),
ItExpr.Is(m => m.Method == HttpMethod.Get),
ItExpr.IsAny());
var mockHandler = new Mock(MockBehavior.Strict);
mockHandler
.Protected()
.Setup(
"PostAsync",
ItExpr.Is(m => m.Method == HttpMethod.Post),
ItExpr.IsAny())
.ReturnsAsync(mockResponse);
< /code>
Ich erhalte einen Fehler < /p>
Testmethode psc.csharp.library.apiclient.Tests.APIServicetests.put_Person_Test_valid -Ausnahme:
bowStem.argumentException: Keine geschützte Methode HTTTPMESSAGEMESSGELEGE. kompatibel mit den angegebenen Argumenten (httprequestMessage, cancellationToken). Mein Quellcode ist auf Github verfügbar.