public void ShouldRejectPathsOutsideOfBasePath(string specifier) { var resolver = new DefaultModuleLoader("file:///project"); var exc = Assert.Throws <ModuleResolutionException>(() => resolver.Resolve("file:///project/folder/script.js", specifier)); Assert.StartsWith(exc.ResolverAlgorithmError, "Unauthorized Module Path"); Assert.StartsWith(exc.Specifier, specifier); }
public void ShouldResolveBareSpecifiers() { var resolver = new DefaultModuleLoader("/"); var resolved = resolver.Resolve(null, "my-module"); Assert.Equal("my-module", resolved.Specifier); Assert.Equal("my-module", resolved.Key); Assert.Equal(null, resolved.Uri?.AbsoluteUri); Assert.Equal(SpecifierType.Bare, resolved.Type); }
public void ShouldResolveRelativePaths(string specifier, string expectedUri) { var resolver = new DefaultModuleLoader("file:///project"); var resolved = resolver.Resolve("file:///project/folder/script.js", specifier); Assert.Equal(specifier, resolved.Specifier); Assert.Equal(expectedUri, resolved.Key); Assert.Equal(expectedUri, resolved.Uri?.AbsoluteUri); Assert.Equal(SpecifierType.RelativeOrAbsolute, resolved.Type); }
public void Test() { using (ShimsContext.Create()) { using (var cc = new TypeCatalog(typeof(TestHandler))) { var loader = new DefaultModuleLoader <IModule>(cc, "Fu"); var modules = loader.GetModules().ToList(); Assert.Equal(1, modules.Count()); var module = modules.First(); Assert.Equal("Bar", module.Item1); Assert.True(module.Item2 is TestHandler); } } }