public void Locate_should_throw_exception_when_file_does_not_exist() { _locator = new WebAssetLocator(false, _pathResolver.Object, _fileSystem.Object); _pathResolver.Setup(resolver => resolver.Resolve(It.IsAny<string>())).Returns((string p) => p.Substring(1)); Assert.Throws<FileNotFoundException>(() => _locator.Locate("~/content/site.css")); }
public void Locate_should_return_same_path_when_file_does_not_exists() { _locator = new WebAssetLocator(false, _pathResolver.Object, _fileSystem.Object); _pathResolver.Setup(resolver => resolver.Resolve(It.IsAny<string>())).Returns((string p) => p.Substring(1)); _fileSystem.Setup(fs => fs.FileExists("/content/site.css")).Returns(true); string path = _locator.Locate("~/content/site.css"); Assert.Equal("~/content/site.css", path); }
public void Locate_should_return_correct_path_in_debug_mode() { _locator = new WebAssetLocator(true, _pathResolver.Object, _fileSystem.Object); _pathResolver.Setup(resolver => resolver.Resolve(It.IsAny<string>())).Returns((string p) => p.Substring(1)); _fileSystem.Setup(fs => fs.FileExists("/scripts/jquery-1.3.2.debug.js")).Returns(true); string path = _locator.Locate("~/scripts/jquery-1.3.2.js"); Assert.Equal("~/scripts/jquery-1.3.2.debug.js", path); }
private static IWebAssetItemMerger CreateAssetMerger(ControllerContext context) { IPathResolver pathResolver = new PathResolver(); IFileSystem fileSystem = new FileSystemWrapper(); IUrlResolver urlResolver = new UrlResolver(new UrlHelper(context.RequestContext)); IWebAssetLocator assetLocator = new WebAssetLocator(context.HttpContext.IsDebuggingEnabled, pathResolver, fileSystem); ICacheManager cacheManager = new CacheManagerWrapper(); IWebAssetRegistry assetRegistry = new WebAssetRegistry(cacheManager, assetLocator, pathResolver, fileSystem); IWebAssetItemMerger assetItemMerger = new WebAssetItemMerger(assetRegistry, urlResolver, context.HttpContext.Server); return assetItemMerger; }
public WebAssetLocatorTests() { cache = new Mock<ICache>(); cache.Setup(c => c.Get<string>(It.IsAny<string>(), It.IsAny<Func<string>>())).Returns((string key, Func<string> defaultValue) => defaultValue()); provider = new Mock<IVirtualPathProvider>(); provider.Setup(p => p.GetFile(It.IsAny<string>())).Returns((string p) => Path.GetFileName(p)); provider.Setup(p => p.GetDirectory(It.IsAny<string>())).Returns((string p) => p.Replace("/" + Path.GetFileName(p), string.Empty)); provider.Setup(p => p.GetExtension(It.IsAny<string>())).Returns((string p) => Path.GetExtension(p)); provider.Setup(p => p.CombinePaths(It.IsAny<string>(), It.IsAny<string>())).Returns((string p1, string p2) => p1 + "/" + p2); locator = new WebAssetLocator(cache.Object, provider.Object, new DebugWebAssetExtensions()); }
public WebAssetLocatorTests() { cache = new Mock <ICache>(); cache.Setup(c => c.Get <string>(It.IsAny <string>(), It.IsAny <Func <string> >())).Returns((string key, Func <string> defaultValue) => defaultValue()); provider = new Mock <IVirtualPathProvider>(); provider.Setup(p => p.GetFile(It.IsAny <string>())).Returns((string p) => Path.GetFileName(p)); provider.Setup(p => p.GetDirectory(It.IsAny <string>())).Returns((string p) => p.Replace("/" + Path.GetFileName(p), string.Empty)); provider.Setup(p => p.GetExtension(It.IsAny <string>())).Returns((string p) => Path.GetExtension(p)); provider.Setup(p => p.CombinePaths(It.IsAny <string>(), It.IsAny <string>())).Returns((string p1, string p2) => p1 + "/" + p2); locator = new WebAssetLocator(cache.Object, provider.Object, new DebugWebAssetExtensions()); }