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 <Uri>())) .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()); }
public void TestQueryAsync_SamplingPointIdIsEmpty_Throws() { var target = new NfieldSamplingPointInterviewerAssignmentsService(); Assert.Throws <ArgumentException>(() => UnwrapAggregateException(target.QueryAsync(SurveyId, ""))); }