Ejemplo n.º 1
0
        public void GetMediaContentShouldReturnMedia()
        {
            string contentTypeImageJpeg = "image/jpeg";

            byte[] imageBytes      = Encoding.UTF8.GetBytes("image-body");
            var    successResponse = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new ByteArrayContent(imageBytes),
            };

            successResponse.Content.Headers.Add(Constants.Api.ContentTypeHeader, contentTypeImageJpeg);

            Mock <HttpMessageHandler> handlerMock = Auth.Tests.Common.Http.SetupMockMessageHandler(successResponse);
            var httpClient = new HttpClient(handlerMock.Object);

            DocScanClient docScanClient = new DocScanClient(_sdkId, _keyPair, httpClient);

            MediaValue mediaValue = docScanClient.GetMediaContent(_someSessionId, _someMediaId);

            Assert.IsTrue(imageBytes.SequenceEqual(mediaValue.GetContent()));
            Assert.AreEqual(contentTypeImageJpeg, mediaValue.GetMIMEType());
        }
Ejemplo n.º 2
0
        public IActionResult Media(string mediaId, string sessionId)
        {
            MediaValue media = _client.GetMediaContent(sessionId, mediaId);

            return(File(media.GetContent(), media.GetMIMEType()));
        }