public void ResolvingStaticRoutesHandling() { RouteTable.Routes.Clear(); IWindsorContainer container = new WindsorContainer(); InitializeWindsor(ref container); AssemblyResourceProvider provider = new AssemblyResourceProvider(); string path = @"Data\Avatars\default.png"; string fp = Assembly.GetExecutingAssembly().CodeBase; fp = Path.GetDirectoryName(path); fp = Path.GetDirectoryName(path); fp = Path.GetDirectoryName(path); fp = Path.Combine(fp, path); try { if (provider.FileExists("/data/Avatar/default.png")) { provider.GetFile("/data/Avatar/default.png"); } } catch { Assert.Pass(); } Assert.Fail(); }
public static void AppInitialize() { // we create a new instance of our own VirtualPathProvider. AssemblyResourceProvider providerInstance = new AssemblyResourceProvider(); // any settings about your VirtualPathProvider may go here. // we get the current instance of HostingEnvironment class. We can't create a new one // because it is not allowed to do so. An AppDomain can only have one HostingEnvironment // instance. HostingEnvironment hostingEnvironmentInstance = (HostingEnvironment)typeof(HostingEnvironment).InvokeMember("_theHostingEnvironment", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null); if (hostingEnvironmentInstance == null) { return; } // we get the MethodInfo for RegisterVirtualPathProviderInternal method which is internal // and also static. MethodInfo mi = typeof(HostingEnvironment).GetMethod("RegisterVirtualPathProviderInternal", BindingFlags.NonPublic | BindingFlags.Static); if (mi == null) { return; } // finally we invoke RegisterVirtualPathProviderInternal method with one argument which // is the instance of our own VirtualPathProvider. mi.Invoke(hostingEnvironmentInstance, new object[] { (VirtualPathProvider)providerInstance }); }
public static void BootStrap() { VirtualPathProvider pathProvider = new AssemblyResourceProvider(); RegisterPathProvider(pathProvider); //ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new InputBuilderViewEngine(new string[0])); }
public static void BootStrap() { VirtualPathProvider pathProvider = new AssemblyResourceProvider(); RegisterPathProvider(pathProvider); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new InputBuilderViewEngine(new[] {"{1}", "Shared"})); }
public virtual void RegisterTheViewsInTheEmbeddedViewEngine(Type areaRegistrationType) { AssemblyResourceProvider.AddResource( new AssemblyResource() { VirtualPath = GetVirtualPath(AreaName), TypeToLocateAssembly = areaRegistrationType, Namespace = GetNamespace(areaRegistrationType) }); }
public void FilesInClientResourcesFolder_ShouldLoad(string path) { // Arrange var provider = new AssemblyResourceProvider(); // Act var result = provider.GetFile("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources" + path); // Assert Assert.NotNull(result); }
public void FilesInClientResourcesFolder_ShouldExist(string path) { // Arrange var provider = new AssemblyResourceProvider(); // Act var result = provider.FileExists("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources" + path); // Assert Assert.True(result); }
public void GetFile_should_return_virtual_file() { //arrange var provider = new AssemblyResourceProvider(); //act var result = provider.GetFile("~/Views/InputBuilders/String.aspx"); //assert Assert.IsNotNull(result); }
public void FilesNotInClientResourcesFolder_ShouldNotExist(string path) { // Arrange var provider = new AssemblyResourceProvider(); // Act var result = provider.FileExists(path); // Assert Assert.False(result); }
public void GetCacheKey_should_return_null() { //arrange var provider = new AssemblyResourceProvider(); //act var result = provider.GetCacheKey(""); //assert Assert.IsNull(result); }
public void App_resource_path_should_find_input_builders() { //arrange var provider = new AssemblyResourceProvider(); //act var result = provider.IsAppResourcePath("~/Views/InputBuilders/String.aspx"); //assert Assert.IsTrue(result); }
public void Get_cache_dep_should_return_null_for_builders() { //arrange var provider = new AssemblyResourceProvider(); //act var result = provider.GetCacheDependency("~/Views/InputBuilders/foo.aspx", new string[0], DateTime.Now); //assert Assert.IsNull(result); }
public void File_exists() { //arrange var provider = new AssemblyResourceProvider(); //act var result = provider.FileExists("~/foo"); //assert Assert.IsFalse(result); }
public void GetFileHash_ShouldWork() { // Arrange var provider = new AssemblyResourceProvider(); // Act var result = provider.GetFileHash("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/fa5/css/all.min.css", new string[0]); // Assert Assert.NotNull(result); Assert.Equal("b03f3a2c".Length, result.Length); }
public void GetCacheKey_ShouldReturnNull() { // Arrange var provider = new AssemblyResourceProvider(); const string virtualPath = "~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/css/all.min.css"; // Act var result = provider.GetCacheKey(virtualPath); // Assert Assert.Null(result); }
public static void BootStrap() { if (!ViewEngines.Engines.Any(engine => engine.GetType().Equals(typeof(InputBuilderViewEngine)))) { VirtualPathProvider pathProvider = new AssemblyResourceProvider(); RegisterPathProvider(pathProvider); var resourceStore = new AssemblyResourceStore(typeof(PortableAreaRegistration), "/areas", typeof(PortableAreaRegistration).Namespace); AssemblyResourceManager.RegisterAreaResources(resourceStore); ViewEngines.Engines.Add(new InputBuilderViewEngine(new string[0])); } }
public void GetCacheDependency_ShouldNeverExpire() { // Arrange var provider = new AssemblyResourceProvider(); const string virtualPath = "~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/fa5/css/all.min.css"; // Act var result = provider.GetCacheDependency(virtualPath, new string[0], DateTime.Now); // Assert Assert.IsType <NeverExpiresCacheCacheDependency>(result); Assert.False(result.HasChanged); Assert.Equal(new DateTime(), result.UtcLastModified); }
public WebsiteResourceLocator( AssemblyResourceProvider assemblyResourceProvider ) { _assemblyResourceProvider = assemblyResourceProvider; }