public void TestGetInvitationStatusAsync_BatchDataIsNull_Throws() { var target = new NfieldSurveyInviteRespondentsService(); Assert.Throws <ArgumentNullException>(() => UnwrapAggregateException(target.GetInvitationStatusAsync(SurveyId, null))); }
public void TestGetInvitationStatusAsync_ProvideBatchName_ReturnsData() { const string batchName = "TestBatch"; const string respondentKey = "TestRespondent"; const string expectedStatus = "Test"; var mockedNfieldConnection = new Mock <INfieldConnectionClient>(); var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection); var target = new NfieldSurveyInviteRespondentsService(); target.InitializeNfieldConnection(mockedNfieldConnection.Object); var expectedResult = new { RespondentKey = respondentKey, Status = expectedStatus }; var url = new Uri(ServiceAddress, $"Surveys/{SurveyId}/InviteRespondents/InvitationStatus/{batchName}"); mockedHttpClient.Setup(client => client.GetAsync(url)) .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(new[] { expectedResult })))); var result = target.GetInvitationStatusAsync(SurveyId, batchName).Result.ToArray(); Assert.Equal(1, result.Length); Assert.Equal(respondentKey, result[0].RespondentKey); Assert.Equal(expectedStatus, result[0].Status); }
public void TestGetInvitationStatusAsync_SurveyIdIsWhitespace_Throws() { var target = new NfieldSurveyInviteRespondentsService(); Assert.Throws <ArgumentException>(() => UnwrapAggregateException(target.GetInvitationStatusAsync(" ", null))); }