Last active
August 29, 2015 13:57
-
-
Save brunomlopes/9418841 to your computer and use it in GitHub Desktop.
Test for problem with ServicesStack's ResourceVirtualDirectory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Reflection; | |
| using Funq; | |
| using NUnit.Framework; | |
| using ServiceStack.IO; | |
| using ServiceStack.VirtualPath; | |
| namespace ServiceStack.Common.Tests.VirtualPathProvider | |
| { | |
| [TestFixture] | |
| class EmbeddedResourceVirtualPathDirectoryTests | |
| { | |
| [Test] | |
| public void WithAnEmbeddedResource_ShouldBeAbleToFindItInVirtualDirectoryWalk() | |
| { | |
| var thisAssembly = GetType().Assembly; | |
| var appHost = new FakeAppHost("fake", thisAssembly); | |
| var directory = new ResourceVirtualDirectory(new InMemoryVirtualPathProvider(appHost), null, GetType().Assembly); | |
| var resourceFiles = WalkForFiles(directory).ToList(); | |
| Assert.IsNotEmpty(resourceFiles); | |
| Assert.Contains("/VirtualPathProvider/ResourceFile.txt", resourceFiles); | |
| } | |
| private IEnumerable<string> WalkForFiles(IVirtualDirectory resourceVirtualDirectory) | |
| { | |
| return resourceVirtualDirectory.Directories.SelectMany(WalkForFiles) | |
| .Concat(resourceVirtualDirectory.Files.Select(f => f.VirtualPath)); | |
| } | |
| class FakeAppHost : AppHostBase | |
| { | |
| public FakeAppHost(string serviceName, params Assembly[] assembliesWithServices) | |
| : base(serviceName, assembliesWithServices) | |
| { | |
| } | |
| public override void Configure(Container container) | |
| { | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Add the ResourceFile.txt to the test project, set compiling action to "Embedded Resource". | |
| Add the test and run it. It should fail. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this file left empty on purpose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment