Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public virtual void RetrieveBytesFromLocalWithResourceSizeByteLimitTest()
        {
            String fileName = "retrieveStyleSheetTest.css.dat";
            // retrieveStyleSheetTest.css.dat size is 89 bytes
            IResourceRetriever retriever        = new DefaultResourceRetriever().SetResourceSizeByteLimit(89);
            ResourceResolver   resourceResolver = new ResourceResolver(baseUri, retriever);

            byte[] bytes = resourceResolver.RetrieveBytesFromResource(fileName);
            Assert.NotNull(bytes);
            Assert.AreEqual(((DefaultResourceRetriever)retriever).GetResourceSizeByteLimit(), bytes.Length);
        }
Exemplo n.º 3
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>());
 }