public void StaticFileLocator() { var settings = new Settings(); var locator = new DefaultStaticFileLocator(VirtualFileLocator.Default, settings); Assert.Collection(locator.Find(@"D:\Project\wwwroot"), f => { Assert.Equal("core.js", f.FileName); Assert.Equal("lib/jslib/core.js", f.RelativePath.ToString()); Assert.Equal("lib/jslib", f.Container); }, f => { Assert.Equal("site.js", f.FileName); Assert.Equal("js/site.js", f.RelativePath.ToString()); Assert.Equal("js", f.Container); }, f => { Assert.Equal("site.css", f.FileName); Assert.Equal("css/site.css", f.RelativePath.ToString()); Assert.Equal("css", f.Container); }, f => { Assert.Equal("favicon.ico", f.FileName); Assert.Equal("favicon.ico", f.RelativePath.ToString()); Assert.Equal("", f.Container); } ); }
public void AddStaticFiles() { var settings = new Tools.Settings(); var staticFileLocator = new DefaultStaticFileLocator(VirtualFileLocator.Default, settings); var staticFiles = staticFileLocator.Find(VirtualFileLocator.ProjectRoot_wwwroot); var staticFileGeneratorService = new StaticFileGeneratorService(new[] { staticFileLocator }, new Tools.Settings()); var c = SyntaxFactory.ClassDeclaration("Test"); c = staticFileGeneratorService.AddStaticFiles(c, string.Empty, staticFiles); Assert.Collection(c.Members, m => { var pathClass = m.AssertIsClass("css"); Assert.Collection(pathClass.Members, m2 => m2.AssertIsSingleField("site_css")); }, m => { var pathClass = m.AssertIsClass("js"); Assert.Collection(pathClass.Members, m2 => m2.AssertIsSingleField("site_js")); }, m => { var pathClass = m.AssertIsClass("lib"); Assert.Collection(pathClass.Members, m2 => { var pathClass2 = m2.AssertIsClass("jslib"); Assert.Collection(pathClass2.Members, m3 => m3.AssertIsSingleField("core_js")); }); }, m => m.AssertIsSingleField("favicon_ico") ); }
public void StaticFileLocator_Exclusions() { var settings = new Settings { ExcludedStaticFileExtensions = new[] { ".ico", ".css" } }; var locator = new DefaultStaticFileLocator(VirtualFileLocator.Default, settings); Assert.Collection(locator.Find(@"D:\Project\wwwroot"), f => Assert.Equal("lib/jslib/core.js", f.RelativePath.ToString()), f => Assert.Equal("js/site.js", f.RelativePath.ToString()) ); }