void CollectReference(AssetReference reference)
 {
     CollectedReferences.Add(new CollectedReference
     {
         SourceBundle = currentBundle,
         AssetReference = reference
     });
 }
Beispiel #2
0
 XElement ReferenceElement(AssetReference reference)
 {
     return new XElement(
         "Reference",
         new XAttribute("Path", reference.ToPath),
         new XAttribute("Type", Enum.GetName(typeof(AssetReferenceType), reference.Type)),
         new XAttribute("SourceLineNumber", reference.SourceLineNumber.ToString(CultureInfo.InvariantCulture))
     );
 }
Beispiel #3
0
        public void ConstructorAssignsProperties()
        {
            var asset = new StubAsset();
            var reference = new AssetReference(asset.Path, "~/path", 1, AssetReferenceType.DifferentBundle);

            reference.FromAssetPath.ShouldBeSameAs(asset.Path);
            reference.ToPath.ShouldEqual("~/path");
            reference.SourceLineNumber.ShouldEqual(1);
            reference.Type.ShouldEqual(AssetReferenceType.DifferentBundle);
        }
Beispiel #4
0
        public void ConstructorAssignsProperties()
        {
            var asset = Mock.Of<IAsset>();
            var reference = new AssetReference("~/path", asset, 1, AssetReferenceType.DifferentBundle);

            reference.Path.ShouldEqual("~/path");
            reference.SourceAsset.ShouldBeSameAs(asset);
            reference.SourceLineNumber.ShouldEqual(1);
            reference.Type.ShouldEqual(AssetReferenceType.DifferentBundle);
        }
        public void GivenAssetWithReferenceToNonexistantFileAndBundleIsFromDescriptorFile_WhenBuildReferences_ThenAssetReferenceIsIgnored()
        {
            var bundle = new TestableBundle("~");
            var asset = new StubAsset();
            var badReference = new AssetReference(asset.Path, "~/NOT-FOUND.js", 1, AssetReferenceType.DifferentBundle);
            asset.ReferenceList.Add(badReference);
            bundle.Assets.Add(asset);
            bundle.DescriptorFilePath = "~/bundle.txt";
            collection.Add(bundle);

            Assert.DoesNotThrow(
                () => collection.BuildReferences()
            );
        }
 bool ShouldCollectReference(AssetReference reference)
 {
     return validTypes.Contains(reference.Type);
 }
 string CreateAssetReferenceNotFoundMessage(AssetReference reference)
 {
     if (reference.SourceLineNumber > 0)
     {
         return string.Format(
             "Reference error in \"{0}\", line {1}. Cannot find \"{2}\".",
             reference.SourceAsset.SourceFile.FullPath, reference.SourceLineNumber, reference.Path
         );
     }
     else
     {
         return string.Format(
             "Reference error in \"{0}\". Cannot find \"{1}\".",
             reference.SourceAsset.SourceFile.FullPath, reference.Path
         );
     }
 }
 bool IsUrlReferenceNotYetSeen(AssetReference reference)
 {
     var isUrl = reference.Type == AssetReferenceType.Url;
     var alreadySeenUrl = existingUrls.Contains(reference.ToPath);
     return isUrl && !alreadySeenUrl;
 }
        public void GivenAssetWithReferenceToNonexistantFileAndBundleIsFromDescriptorFile_WhenConstructed_ThenAssetReferenceIsIgnored()
        {
            var bundle = new TestableBundle("~");
            var asset = new StubAsset();
            var badReference = new AssetReference("~/NOT-FOUND.js", asset, 1, AssetReferenceType.DifferentBundle);
            asset.References.Add(badReference);
            bundle.Assets.Add(asset);

            bundle.IsFromDescriptorFile = true;

            Assert.DoesNotThrow(
                () => new BundleContainer(new[] { bundle })
            );
        }