/// <summary> /// Throws an exception if any file doesn't match one of the specified file extensions. /// </summary> public static IAsset EnforceFileExtensions(this IAsset asset, params string[] extensions) { var processor = new EnforceFileExtensions(extensions); asset.Processors.Add(processor); return asset; }
public async Task EnforceExtension_Throws(string fileName, params string[] extensions) { var minifier = new EnforceFileExtensions(extensions); var context = new Mock <IAssetContext>().SetupAllProperties(); context.Object.Content = new Dictionary <string, byte[]> { { fileName, new byte[0] } }; var options = new Mock <WebOptimizerOptions>(); await Assert.ThrowsAsync <NotSupportedException>(async() => await minifier.ExecuteAsync(context.Object)); }
public async Task EnforceExtension_Success(string fileName, params string[] extensions) { var minifier = new EnforceFileExtensions(extensions); var context = new Mock <IAssetContext>().SetupAllProperties(); context.Object.Content = new Dictionary <string, byte[]> { { fileName, new byte[0] } }; var options = new Mock <WebOptimizerOptions>(); await minifier.ExecuteAsync(context.Object); Assert.Equal(fileName, context.Object.Content.First().Key); }