SamplingPointQuotaTargetUpdateAsync() public method

See INfieldSurveysService.SamplingPointQuotaTargetUpdateAsync
public SamplingPointQuotaTargetUpdateAsync ( string surveyId, string samplingPointId, SamplingPointQuotaTarget samplingPointQuotaTarget ) : Task
surveyId string
samplingPointId string
samplingPointQuotaTarget Nfield.Models.SamplingPointQuotaTarget
return Task
コード例 #1
0
        public void TestSamplingPointQuotaTargetUpdateAsync_SamplingPointQuotaTargetExists_ReturnsSamplingPointQuotaTarget()
        {
            const string levelId = "LevelId";
            const string surveyId = "SurveyId";
            const string samplingPointId = "SamplingPointId";

            var samplingPointQuotaTarget = new SamplingPointQuotaTarget
            {
                LevelId = levelId,
                Target = 10
            };
            var mockedNfieldConnection = new Mock<INfieldConnectionClient>();
            var mockedHttpClient = CreateHttpClientMock(mockedNfieldConnection);
            mockedHttpClient
                .Setup(
                    client =>
                        client.PatchAsJsonAsync<UpdateSamplingPointQuotaTarget>(
                            string.Format("{0}surveys/{1}/samplingpoints/{2}/quotatargets/{3}", ServiceAddress, surveyId,
                                samplingPointId, levelId), It.IsAny<UpdateSamplingPointQuotaTarget>()))
                .Returns(CreateTask(HttpStatusCode.OK,
                    new StringContent(JsonConvert.SerializeObject(samplingPointQuotaTarget))));

            var target = new NfieldSurveysService();
            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.SamplingPointQuotaTargetUpdateAsync(surveyId,samplingPointId,samplingPointQuotaTarget).Result;

            Assert.Equal(samplingPointQuotaTarget.Target, actual.Target);
        }
コード例 #2
0
 public void TestSamplingPointQuotaTargetUpdateAsync_SamplingPointQuotaTargetArgumentIsNull_ThrowsArgumentNullException()
 {
     var target = new NfieldSurveysService();
     Assert.Throws<ArgumentNullException>(
         () =>
         {
             try
             {
                 target.SamplingPointQuotaTargetUpdateAsync("", "", null).Wait();
             }
             catch (AggregateException ex)
             {
                 throw ex.InnerException;
             }
         }
         );
 }