public QueryAsync ( string surveyId, string samplingPointId ) : Task |
||
surveyId | string | |
samplingPointId | string | |
리턴 | Task |
public void TestQueryAsync_SurveyIdIsNull_Throws() { var target = new NfieldSamplingPointInterviewerAssignmentsService(); Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.QueryAsync(null, SamplingPointId))); }
public void TestQueryAsync_ServerReturnsQuery_ReturnsListWithAssignments() { var expectedAssignments = new [] { new InterviewerSamplingPointAssignmentModel {Active = false, Assigned = false, FirstName = "fn1", InterviewerId = "id1", LastName = "ln1", UserName = "******"}, new InterviewerSamplingPointAssignmentModel {Active = true, Assigned = true, FirstName = "fn2", InterviewerId = "id2", LastName = "ln2", UserName = "******"} }; var mockedNfieldConnection = new Mock<INfieldConnectionClient>(); var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection); mockedHttpClient.Setup(client => client.GetAsync(It.IsAny<string>())) .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedAssignments)))); var target = new NfieldSamplingPointInterviewerAssignmentsService(); target.InitializeNfieldConnection(mockedNfieldConnection.Object); var actualAssignments = target.QueryAsync(SurveyId, SamplingPointId).Result; Assert.Equal(expectedAssignments[0].InterviewerId, actualAssignments.ToArray()[0].InterviewerId); Assert.Equal(expectedAssignments[1].InterviewerId, actualAssignments.ToArray()[1].InterviewerId); Assert.Equal(2, actualAssignments.Count()); }