Exemplo n.º 1
0
        public void SingleTargetFramework()
        {
            LockFile lockFile = GetLockFileWithSingleTargetFramework();

            ProjectRootElement project = ValidateProject(lockFile);

            ProjectItemGroupElement itemGroupElement = project.ItemGroups.ShouldHaveSingleItem();

            foreach (LockFileTargetLibrary targetLibrary in lockFile.Targets[0].Libraries)
            {
                ProjectItemElement itemElement = itemGroupElement.Items.FirstOrDefault(x => x.Include.Equals(targetLibrary.Name));

                itemElement.ShouldNotBeNull();

                ProjectMetadataElement versionMetadataElement = itemElement.Metadata.FirstOrDefault(x => x.Name.Equals("Version"));

                versionMetadataElement.ShouldNotBeNull();

                versionMetadataElement.Value.ShouldBe($"[{targetLibrary.Version.ToString()}]");
            }

            itemGroupElement.Items.Count.ShouldBe(lockFile.Targets.Aggregate(0, (count, target) => target.Libraries.Count));
        }
Exemplo n.º 2
0
        public void SingleTargetFrameworkWithIncludeAssetsAndPrivateAssets()
        {
            LockFile lockFile = GetLockFileWithSingleTargetFramework();

            ProjectRootElement project = ValidateProject(lockFile);

            ProjectItemGroupElement itemGroupElement = project.ItemGroups.ShouldHaveSingleItem();

            itemGroupElement.Items.ShouldContain(i => i.Include.Equals("Package3"), 1);

            var itemElement = itemGroupElement.Items.Single(i => i.Include.Equals("Package3"));

            ProjectMetadataElement includeAssetsMetadataElement = itemElement.Metadata.FirstOrDefault(i => i.Name.Equals("IncludeAssets"));

            includeAssetsMetadataElement.ShouldNotBeNull();

            includeAssetsMetadataElement.Value.ShouldBe("Runtime;ContentFiles");

            ProjectMetadataElement privateAssetsMetadataElement = itemElement.Metadata.FirstOrDefault(i => i.Name.Equals("PrivateAssets"));

            privateAssetsMetadataElement.ShouldNotBeNull();

            privateAssetsMetadataElement.Value.ShouldBe("Native");
        }