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

            NUnit.Framework.Assert.NotNull(stream);
        }
コード例 #2
0
        public virtual void RetrieveResourceAsInputStreamByMalformedResourceNameTest()
        {
            String           fileName         = "retrieveStyl eSheetTest.css";
            ResourceResolver resourceResolver = new ResourceResolver(baseUri);
            Stream           stream           = resourceResolver.RetrieveResourceAsInputStream(fileName);

            Assert.Null(stream);
        }
コード例 #3
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());
        }
コード例 #4
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);
        }
コード例 #5
0
        public virtual void RetrieveResourceAsInputStreamAbsolutePathTest()
        {
            String fileName     = "retrieveStyleSheetTest.css";
            String absolutePath = Path.Combine(baseUri, fileName).ToFile().FullName;

            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            using (Stream stream = resourceResolver.RetrieveResourceAsInputStream(absolutePath),
                   expected = new FileStream(absolutePath, FileMode.Open, FileAccess.Read)) {
                Assert.NotNull(stream);
                Assert.AreEqual(expected.Read(), stream.Read());
            }
        }
コード例 #6
0
        public virtual void RetrieveResourceAsInputStreamFileUrlTest()
        {
            String fileName      = "retrieveStyleSheetTest.css";
            Uri    url           = Path.Combine(baseUri, fileName).ToUri().ToUrl();
            String fileUrlString = url.ToExternalForm();

            ResourceResolver resourceResolver = new ResourceResolver(baseUri);

            using (Stream stream = resourceResolver.RetrieveResourceAsInputStream(fileUrlString),
                   expected = UrlUtil.OpenStream(url)) {
                Assert.NotNull(stream);
                Assert.AreEqual(expected.Read(), stream.Read());
            }
        }
コード例 #7
0
 public virtual void AttemptToReadBytesFromLimitedInputStreamTest()
 {
     NUnit.Framework.Assert.That(() => {
         String fileName = "retrieveStyleSheetTest.css";
         // retrieveStyleSheetTest.css size is 89 bytes
         IResourceRetriever retriever      = new DefaultResourceRetriever().SetResourceSizeByteLimit(40);
         ResourceResolver resourceResolver = new ResourceResolver(baseUri, retriever);
         Stream stream = resourceResolver.RetrieveResourceAsInputStream(fileName);
         for (int i = 0; i < 41; i++)
         {
             stream.Read();
         }
     }
                                 , NUnit.Framework.Throws.InstanceOf <ReadingByteLimitException>());
 }