Beispiel #1
0
        public void TestCreateOrUpdateOnlineQuotaAsync_ReturnsCorrectQuotaFrame()
        {
            const string surveyId = "surveyId";
            var          uri      = new Uri(ServiceAddress, "Surveys/" + surveyId + "/Quota");

            var quotaFrame = new QuotaFrame
            {
                Target = 10
            };

            var mockedNfieldConnection = new Mock <INfieldConnectionClient>();
            var mockedHttpClient       = CreateHttpClientMock(mockedNfieldConnection);

            mockedHttpClient
            .Setup(client => client.PutAsJsonAsync(uri, quotaFrame))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(quotaFrame))));

            var target = new NfieldSurveysService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actualQuotaFrame = target.CreateOrUpdateOnlineQuotaAsync(surveyId, quotaFrame).Result;

            Assert.Equal(10, actualQuotaFrame.Target);
        }