public void TestGetAsync_ReturnsCorrectResults() { var expectedInterviewers = new[] { new SurveyInterviewerAssignmentModel {InterviewerId = "id1", IsActive = true, IsAssigned = true}, new SurveyInterviewerAssignmentModel {InterviewerId = "id2", IsActive = false, IsAssigned = false} }; const string surveyId = "surveyId"; var mockedNfieldConnection = new Mock<INfieldConnectionClient>(); var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection); mockedHttpClient.Setup(client => client.GetAsync(It.Is<string>(url => url.EndsWith("Surveys/" + surveyId + "/Interviewers/")))) .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedInterviewers)))); var target = new NfieldSurveyInterviewersService(); target.InitializeNfieldConnection(mockedNfieldConnection.Object); // Act var actual = target.GetAsync(surveyId).Result.ToArray(); // Assert Assert.Equal(expectedInterviewers.Length, actual.Length); Assert.Equal(expectedInterviewers[0].InterviewerId, actual[0].InterviewerId); Assert.Equal(expectedInterviewers[0].IsActive, actual[0].IsActive); Assert.Equal(expectedInterviewers[0].IsAssigned, actual[0].IsAssigned); Assert.Equal(expectedInterviewers[1].InterviewerId, actual[1].InterviewerId); Assert.Equal(expectedInterviewers[1].IsActive, actual[1].IsActive); Assert.Equal(expectedInterviewers[1].IsAssigned, actual[1].IsAssigned); }
public void TestGetAsync_SurveyIdIsNull_Throws() { var target = new NfieldSurveyInterviewersService(); Assert.Throws<ArgumentNullException>( () => UnwrapAggregateException(target.GetAsync(null))); }