skroonenburg / Rejuicer

Fluent CSS & JavaScript minification tool for ASP.NET.
http://rejuice.me
14 stars 9 forks source link

Add ability to override VirtualPathResolver #1

Open Daniel15 opened 12 years ago

Daniel15 commented 12 years ago

As far as I can see, FileResolver is an internal class so a custom/stub implementation of VirtualPathResolver can't be added. This may be beneficial for unit tests, as you've done in the Rejuicer tests (https://github.com/skroonenburg/Rejuicer/blob/master/Source/Rejuicer/Rejuicer-test/FluentConfigurerTests.cs)

In my case, we're hosting multiple sites with the same codebase and are using merge fields in a template (ie. {javascript} inserts references to generic JavaScript files used by every site). There are unit tests around these merge fields and hence Rejuicer is being invoked in the unit tests. I'm having issues stubbing Server.MapPath with Rhino Mocks so I think it'd be easier to just have a custom Virtual PathResolver in Rejuicer.

Daniel15 commented 12 years ago

As an aside, I've found that creating a "fake" HttpContext is sufficient in a unit test to get Rejuicer to not crash:

HttpContext.Current = new HttpContext(new HttpRequest("", "http://tempuri.org/", ""),
                                      new HttpResponse(new StringWriter()));
rythos42 commented 11 years ago

This was incredibly helpful in my feature update #11. Got my 3 new unit tests working with very little trouble!