public virtual void RetrieveAsStreamBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); Stream stream = resourceResolver.RetrieveResourceAsInputStream(bLogo); NUnit.Framework.Assert.NotNull(stream); }
public virtual void RetrieveResourceAsInputStreamByMalformedResourceNameTest() { String fileName = "retrieveStyl eSheetTest.css"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); Stream stream = resourceResolver.RetrieveResourceAsInputStream(fileName); Assert.Null(stream); }
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()); }
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); }
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()); } }
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()); } }
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>()); }