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>(() =>
            {
                target.SamplingPointQuotaTargetUpdateAsync(It.IsAny <string>(), It.IsAny <string>(), null).Wait();
            });
        }
        public void TestSamplingPointQuotaTargetUpdateAsync_SamplingPointQuotaTargetArgumentIsNull_ThrowsArgumentNullException()
        {
            var target = new NfieldSurveysService();

            Assert.Throws <ArgumentNullException>(
                () =>
            {
                try
                {
                    target.SamplingPointQuotaTargetUpdateAsync("", "", null).Wait();
                }
                catch (AggregateException ex)
                {
                    throw ex.InnerException;
                }
            }
                );
        }