示例#1
0
        public void TestOnlineQuotaQueryAsync_ServerReturnsQuery_ReturnsAppropriateQuota()
        {
            var quotaFrame = new QuotaFrame
            {
                Target = 10
            };

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

            mockedHttpClient
            .Setup(client => client.GetAsync(new Uri(ServiceAddress, "Surveys/1/Quota")))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(quotaFrame))));
            var target = new NfieldSurveysService();

            target.InitializeNfieldConnection(mockedNfieldConnection.Object);

            var actualQuotaFrame = target.OnlineQuotaQueryAsync("1").Result;

            mockedHttpClient.Verify(hc => hc.GetAsync(It.IsAny <Uri>()), Times.Once());

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