public void TestAddAsync_ValidSurveyResponseCode_CallsCorrectUrl()
{
// Arrange
const string surveyId = "surveyId";
var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);
var responseCodeToAdd = new SurveyResponseCode
{
ResponseCode = 15,
Description = "Description",
IsDefinite = true,
AllowAppointment = false
};
mockedHttpClient.Setup(client => client.PostAsJsonAsync(It.IsAny<string>(), It.IsAny<SurveyResponseCode>()))
.Returns(CreateTask(HttpStatusCode.OK,
new StringContent(JsonConvert.SerializeObject(new SurveyResponseCode()))));
var target = new NfieldSurveyResponseCodesService();
target.InitializeNfieldConnection(mockedNfieldConnection.Object);
// Act
target.AddAsync(surveyId, responseCodeToAdd).Wait();
// Assert
mockedHttpClient.Verify( hc =>
hc.PostAsJsonAsync(It.Is<string>(url => url.EndsWith("Surveys/" + surveyId + "/ResponseCodes/")), responseCodeToAdd),
Times.Once());
}