jeudi 7 mai 2015

How to mock sendAsync method of httpclient using rhino Mock

I tried the below code but it is throwing exception

System.InvalidOperationException: Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method).

        var mockHttpClient = MockRepository.GenerateStrictMock<HttpClient>();

        HttpResponseMessage fakeResponse = FakeHttpResponseMessage(HttpStatusCode.OK);

        HttpRequestMessage fakeMessage = FakeHttpRequestMessage();

        mockHttpClient.Expect(x => x.SendAsync(fakeMessage)).IgnoreArguments().Return(Task.FromResult(fakeResponse));

Aucun commentaire:

Enregistrer un commentaire