public async Task TestCanGetEntryAsync() { const string endpointUrl = "https://cdn.contentful.com/spaces/spaceId/entries/123456"; var cancellationToken = new CancellationToken(); var mockHttpWrapper = new Mock <IHttpClientWrapper>(); mockHttpWrapper.Setup(m => m.GetAsync(endpointUrl, cancellationToken)) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{ sys: { \"id\": \"123456\" } }") }); var client = new ContentfulClient("spaceId", mockHttpWrapper.Object); var entry = await client.GetAsync <Entry>(cancellationToken, "123456"); Assert.IsNotNull(entry); Assert.AreEqual("123456", entry.SystemProperties.Id); }
public async Task TestCanGetEntryAsync() { const string endpointUrl = "https://cdn.contentful.com/spaces/spaceId/entries/123456"; var cancellationToken = new CancellationToken(); var mockHttpWrapper = new Mock<IHttpClientWrapper>(); mockHttpWrapper.Setup(m => m.GetAsync(endpointUrl, cancellationToken)) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{ sys: { \"id\": \"123456\" } }") }); var client = new ContentfulClient("spaceId", mockHttpWrapper.Object); var entry = await client.GetAsync<Entry>(cancellationToken, "123456"); Assert.IsNotNull(entry); Assert.AreEqual("123456", entry.SystemProperties.Id); }