Ejemplo n.º 1
0
        public void TestSamplingPointUpdateAsync_SamplingPointExists_ReturnsSamplingPoint()
        {
            const string surveyId             = "SurveyId";
            const string samplingPointId      = "SamplingPointId";
            const string samplingPointGroupId = "MyGroupId";

            var samplingPoint = new SamplingPoint
            {
                SamplingPointId = samplingPointId,
                Name            = "Updated",
                GroupId         = samplingPointGroupId
            };
            var mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);

            mockedHttpClient
            .Setup(
                client =>
                client.PatchAsJsonAsync <UpdateSamplingPoint>(
                    string.Format("{0}surveys/{1}/samplingpoints/{2}", ServiceAddress, surveyId,
                                  samplingPointId), It.IsAny <UpdateSamplingPoint>()))
            .Returns(CreateTask(HttpStatusCode.OK,
                                new StringContent(JsonConvert.SerializeObject(samplingPoint))));

            var target = new NfieldSurveysService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actual = target.SamplingPointUpdateAsync(surveyId, samplingPoint).Result;

            Assert.Equal(samplingPoint.Name, actual.Name);
            Assert.Equal(samplingPoint.GroupId, actual.GroupId);
        }
Ejemplo n.º 2
0
        public void TestSamplingPointUpdateAsync_SamplingPointArgumentIsNull_ThrowsArgumentNullException()
        {
            var target = new NfieldSurveysService();

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