Exemple #1
0
        public virtual void RetrieveAsStreamBase64Test()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            Stream           stream           = resourceResolver.RetrieveResourceAsInputStream(bLogo);

            NUnit.Framework.Assert.NotNull(stream);
        }
Exemple #2
0
        public virtual void RetrieveBytesFromResourceCorruptedDataBase64Test()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            byte[] bytes = resourceResolver.RetrieveBytesFromResource(bLogoCorruptedData);
            Assert.Null(bytes);
        }
Exemple #3
0
        public virtual void RetrieveImageExtendedNullTest()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfXObject       image            = resourceResolver.RetrieveImageExtended(null);

            NUnit.Framework.Assert.Null(image);
        }
Exemple #4
0
        public virtual void RetrieveImageExtendedIncorrectBase64Test()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfXObject       image            = resourceResolver.RetrieveImageExtended(bLogoCorruptedData);

            NUnit.Framework.Assert.Null(image);
        }
Exemple #5
0
        public virtual void RetrieveImageExtendedBase64Test()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfXObject       image            = resourceResolver.RetrieveImageExtended(bLogo);

            Assert.NotNull(image);
        }
Exemple #6
0
        public virtual void RetrieveBytesFromResourceIncorrectBase64Test()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            byte[] bytes = resourceResolver.RetrieveBytesFromResource(bLogoIncorrect);
            Assert.Null(bytes);
        }
Exemple #7
0
        public virtual void malformedResourceNameTest()
        {
            String           fileName         = "resourceResolverTest .png";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            resourceResolver.RetrieveStream(fileName);
        }
Exemple #8
0
        public void IncorrectBase64Test()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfXObject       pdfXObject       = resourceResolver.TryResolveBase64ImageSource(bLogoIncorrect);

            NUnit.Framework.Assert.Null(pdfXObject);
        }
Exemple #9
0
        public virtual void RetrieveImageWrongPathTest()
        {
            String           fileName         = "/itextpdf.com/itis.jpg";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfImageXObject  image            = resourceResolver.RetrieveImage(fileName);

            Assert.Null(image);
        }
Exemple #10
0
        public virtual void IsImageTypeSupportedTest()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            Assert.True(resourceResolver.IsImageTypeSupportedByImageDataFactory("resourceResolverTest.png"));
            Assert.False(resourceResolver.IsImageTypeSupportedByImageDataFactory("test.txt"));
            Assert.False(resourceResolver.IsImageTypeSupportedByImageDataFactory("htt://test.png"));
        }
Exemple #11
0
        public virtual void RetrieveImageExtendedByMalformedResourceNameTest()
        {
            String           fileName         = "retrieveStyl eSheetTest.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfXObject       pdfXObject       = resourceResolver.RetrieveImageExtended(fileName);

            Assert.Null(pdfXObject);
        }
Exemple #12
0
        public virtual void RetrieveBytesFromResourceByMalformedResourceNameTest()
        {
            String           fileName         = "retrieveStyl eSheetTest.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            byte[] bytes = resourceResolver.RetrieveBytesFromResource(fileName);
            Assert.Null(bytes);
        }
Exemple #13
0
        public virtual void RetrieveResourceAsInputStreamByMalformedResourceNameTest()
        {
            String           fileName         = "retrieveStyl eSheetTest.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            Stream           stream           = resourceResolver.RetrieveResourceAsInputStream(fileName);

            Assert.Null(stream);
        }
Exemple #14
0
        public void IsDataSrcCheckTest()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            NUnit.Framework.Assert.True(resourceResolver.IsDataSrc(bLogoCorruptedData));
            NUnit.Framework.Assert.True(resourceResolver.IsDataSrc(bLogoIncorrect));
            NUnit.Framework.Assert.False(resourceResolver.IsDataSrc("https://data.com/data"));
        }
Exemple #15
0
        public virtual void RetrieveStreamByMalformedResourceNameTest()
        {
            String           fileName         = "resourceResolverTest .png";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            byte[] bytes = resourceResolver.RetrieveStream(fileName);
            Assert.Null(bytes);
        }
Exemple #16
0
        public void RetrieveBytesMalformedResourceNameTest()
        {
            String           fileName         = "resourceResolverTest .png";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            byte[] bytes = resourceResolver.RetrieveBytesFromResource(fileName);
            NUnit.Framework.Assert.Null(bytes);
        }
Exemple #17
0
        public virtual void ResourceResolverConstructorTest()
        {
            ResourceResolver rr    = new ResourceResolver(null);
            UriResolver      ur    = new UriResolver("");
            String           rrUrl = rr.ResolveAgainstBaseUri("").ToString();
            String           urUrl = ur.ResolveAgainstBaseUri("").ToString();

            NUnit.Framework.Assert.AreEqual(rrUrl, urUrl);
        }
Exemple #18
0
        public virtual void IsDataSrcTest()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            Assert.True(resourceResolver.IsDataSrc(bLogo));
            Assert.True(resourceResolver.IsDataSrc(bLogoCorruptedData));
            Assert.True(resourceResolver.IsDataSrc(bLogoIncorrect));
            Assert.False(resourceResolver.IsDataSrc("https://data.com/data"));
        }
Exemple #19
0
        public void IsImageTypeSupportedMalformedURLTest()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            bool             res = resourceResolver.IsImageTypeSupportedByImageDataFactory("htt://test.png");

            NUnit.Framework.Assert.False(res);
            res = resourceResolver.IsImageTypeSupportedByImageDataFactory("htt://test.png");
            NUnit.Framework.Assert.False(res);
        }
Exemple #20
0
        public virtual void AttemptToRetrieveBytesFromResourceStyleSheetWithFilterRetrieverTest()
        {
            String           fileName         = "retrieveStyleSheetTest.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            resourceResolver.SetRetriever(new FilterResourceRetriever());
            byte[] bytes = resourceResolver.RetrieveBytesFromResource(fileName);
            Assert.Null(bytes);
        }
Exemple #21
0
        public virtual void RetrieveImageRightPathTest()
        {
            String           fileName         = "itextpdf.com/itis.jpg";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfImageXObject  image            = resourceResolver.RetrieveImage(fileName);

            Assert.NotNull(image);
            Assert.IsTrue(image.IdentifyImageFileExtension().EqualsIgnoreCase("jpg"));
        }
Exemple #22
0
        public virtual void RetrieveImageTest()
        {
            String           fileName         = "resourceResolverTest.png";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            PdfImageXObject  image            = resourceResolver.RetrieveImage(fileName);

            NUnit.Framework.Assert.NotNull(image);
            NUnit.Framework.Assert.True(image.IdentifyImageFileExtension().EqualsIgnoreCase("png"));
        }
Exemple #23
0
        public virtual void RetrieveImagePathWithSpacesTest()
        {
            String           fileName         = "retrieveImagePathWithSpaces.jpg";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri + "path with spaces/");
            PdfImageXObject  image            = resourceResolver.RetrieveImage(fileName);

            Assert.NotNull(image);
            Assert.IsTrue(image.IdentifyImageFileExtension().EqualsIgnoreCase("jpg"));
        }
Exemple #24
0
 public virtual void RetrieveStyleSheetByMalformedResourceNameTest()
 {
     NUnit.Framework.Assert.That(() => {
         String fileName = "retrieveStyl eSheetTest.css";
         ResourceResolver resourceResolver = new ResourceResolver(baseUri);
         resourceResolver.RetrieveStyleSheet(fileName);
     }
                                 , NUnit.Framework.Throws.InstanceOf <IOException>());
 }
Exemple #25
0
        public virtual void RetrieveStyleSheetTest()
        {
            String           fileName         = "retrieveStyleSheetTest.css";
            Stream           expected         = new FileStream(baseUri + fileName, FileMode.Open, FileAccess.Read);
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            Stream           stream           = resourceResolver.RetrieveStyleSheet(fileName);

            Assert.NotNull(stream);
            Assert.AreEqual(expected.Read(), stream.Read());
        }
Exemple #26
0
 public virtual void malformedResourceNameTest1()
 {
     NUnit.Framework.Assert.That(() => {
         String fileName = "retrieveStyl eSheetTest.css";
         ResourceResolver resourceResolver = new ResourceResolver(baseUri);
         resourceResolver.RetrieveStyleSheet(fileName);
     }
                                 , NUnit.Framework.Throws.TypeOf <FileNotFoundException>());
     ;
 }
Exemple #27
0
        public void IsImageTypeSupportedTest()
        {
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            String           fileName         = "resourceResolverTest.png";
            bool             res = resourceResolver.IsImageTypeSupportedByImageDataFactory(fileName);

            NUnit.Framework.Assert.True(res);
            res = resourceResolver.IsImageTypeSupportedByImageDataFactory("test.txt");
            NUnit.Framework.Assert.False(res);
        }
Exemple #28
0
        public virtual void AttemptToRetrieveBytesFromLocalWithResourceSizeByteLimitTest()
        {
            String fileName = "retrieveStyleSheetTest.css";
            // retrieveStyleSheetTest.css size is 89 bytes
            IResourceRetriever retriever        = new DefaultResourceRetriever().SetResourceSizeByteLimit(88);
            ResourceResolver   resourceResolver = new ResourceResolver(baseUri, retriever);

            byte[] bytes = resourceResolver.RetrieveBytesFromResource(fileName);
            Assert.Null(bytes);
        }
Exemple #29
0
        public virtual void RetrieveInputStreamWithRetryRetrieverTest()
        {
            String           fileName         = "!invalid! StyleSheetName.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri, new RetryResourceRetriever(baseUri));
            Stream           expected         = new FileStream(baseUri + "retrieveStyleSheetTest.css", FileMode.Open, FileAccess.Read);
            Stream           stream           = resourceResolver.RetrieveResourceAsInputStream(fileName);

            Assert.NotNull(stream);
            Assert.AreEqual(expected.Read(), stream.Read());
        }
Exemple #30
0
        public virtual void AttemptToRetrieveInputStreamWithFilterRetrieverTest()
        {
            String           fileName         = "retrieveStyleSheetTest.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            resourceResolver.SetRetriever(new FilterResourceRetriever());
            Stream stream = resourceResolver.RetrieveResourceAsInputStream(fileName);

            Assert.Null(stream);
        }