B4BCore.CheckBundles.CheckBundleFileIsNotNewerThanMinifiedFiles C# (CSharp) Метод

CheckBundleFileIsNotNewerThanMinifiedFiles() публичный Метод

This checks that the minified files for each bundle is older than the BowerBundles.json file that defines what is in a bundle.
public CheckBundleFileIsNotNewerThanMinifiedFiles ( ) : string
Результат string
        public string CheckBundleFileIsNotNewerThanMinifiedFiles()
        {
            var errors = new List<string>();

            var bundleInfo = new FileWithDateUpdated(_mvcAppPath, _bundleFilePath);

            //Note: we exclude the cdn bundles as the minified file is not normally created by the build process
            var badFiles = (from bundleName in _reader.BundleNames.Where(x => !_reader.GetBundleCdnInfo(x).Any())
                let fileExtension = Path.GetExtension(_reader.GetBundleDebugFiles(bundleName, "", s => errors.Add(s)).First())
                let fileTypeInfo = _config.GetFileTypeData(fileExtension)
                let minfiedFile = new FileWithDateUpdated(_mvcAppPath, Path.Combine(fileTypeInfo.Directory,
                        bundleName + ".min" + fileExtension))
                where !minfiedFile.Exists || minfiedFile.LastWrittenUtc < bundleInfo.LastWrittenUtc
                select minfiedFile.FileRelPath).ToList();

            if (errors.Any())
                return $"Errors in the BowerBundles file: {string.Join("\n", errors)}.";

            return badFiles.Any()
                ? $"The following minified files have not been updated since the change in the bundle file:\n - {string.Join("\n - ", badFiles)}"
                : null;
        }

Usage Example

        public void TestCheckBundleFileIsNotNewerThanMinifiedFilesMvcAppOk()
        {
            //SETUP
            var checker = new CheckBundles(typeof(BowerBundlerHelper));

            //ATTEMPT
            var error = checker.CheckBundleFileIsNotNewerThanMinifiedFiles();

            //VERIFY
            Assert.IsNull(error, error);
        }