コード例 #1
0
        public void TestUpdateAsync_InterviewerExists_ReturnsInterviewer()
        {
            const string surveyId = "aSurveyId";
            var          survey   = new Survey(SurveyType.Basic)
            {
                SurveyId    = surveyId,
                Description = "updated description"
            };
            var mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);

            mockedHttpClient
            .Setup(client => client.PatchAsJsonAsync(ServiceAddress + "surveys/" + surveyId, It.IsAny <UpdateSurvey>()))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(survey))));

            var target = new NfieldSurveysService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.UpdateAsync(survey).Result;

            Assert.Equal(survey.Description, actual.Description);
        }
コード例 #2
0
        public void TestUpdateAsync_SurveyArgumentIsNull_ThrowsArgumentNullException()
        {
            var target = new NfieldSurveysService();

            Assert.Throws <ArgumentNullException>(() => UnwrapAggregateException(target.UpdateAsync(null)));
        }