Example #1
0
        public void TestCancelGetRenderedHtml()
        {
            const string RenderingId  = "{447AA0FC-95C8-4EFD-B64E-FBF880C42E2D}";
            const string DatasourceId = "{44E7C4E6-764E-49ED-9850-9D1435E864CD}";
            var          request      =
                ItemWebApiRequestBuilder.RenderingHtmlRequestWithSourceAndRenderingId(DatasourceId, RenderingId)
                .SourceAndRenderingDatabase(null)
                .Build();
            var    cancelToken = CreateCancelTokenWithDelay(5);
            Stream response    = null;

            TestDelegate testCode = async() =>
            {
                response = await session.ReadRenderingHtmlAsync(request, cancelToken);
            };
            var exception = Assert.Catch <OperationCanceledException>(testCode);

            Assert.IsNull(response);

            //      Desktop (Windows) : "A task was canceled."
            //      iOS               : "The Task was canceled"
            Assert.IsTrue(exception.Message.ToLowerInvariant().Contains("task was canceled"));

            // @adk : CancellationToken class comparison or scheduling works differently on iOS
            // Assert.AreEqual(cancelToken, exception.CancellationToken);
        }
Example #2
0
        private async Task <string> GetStringResponse(ISitecoreWebApiReadonlySession session, IGetRenderingHtmlRequest request)
        {
            var stream = await session.ReadRenderingHtmlAsync(request);

            var response = this.StreamToString(stream);

            return(response);
        }
 private async Task<string> GetStringResponse(ISitecoreWebApiReadonlySession session, IGetRenderingHtmlRequest request)
 {
   var stream = await session.ReadRenderingHtmlAsync(request);
   var response = this.StreamToString(stream);
   return response;
 }