Main service implementation using flurl
Public async Task<ApplicationItemVm> UpdateOpportunityInfo(string optyNumber, UpdateOpportunityVm model, string token = "")
{
var result = await "https://api.com/*"
.WithOAuthBearerToken(token)
.PatchJsonAsync(model)
.ReceiveJson<ApplicationItemVm>();
return result;
}
Test Method using MS Test
[TestMethod]
public async Task UpdateOppTest()
{
var updateOpportunityVm = new UpdateOpportunityVm
{
AboutYouIConfirm_c = true
};
var applicationItemVm = new ApplicationItemVm { AboutYouIConfirm_c=true};
// fake & record all http calls in the test subject
using (var httpTest = new HttpTest())
{
// arrange
httpTest.
RespondWith("OK", 200).RespondWithJson(applicationItemVm);
// act
var application = await applicationService.UpdateOpportunityInfo("optyNumber", updateOpportunityVm, "CloudToken");
// assert
httpTest.ShouldHaveCalled("https://api.com/*")
.WithVerb(HttpMethod.Patch)
.WithContentType("application/json");
}
}
After test method execution got following error
Response could nor deserilize
Let me know if I need to add more details.
Please suggest what's wrong I am doing.
Expected Result I want to mock request and response when I calling the main service method but unfortunately I not able to do