public void GetPackageDownloads_WhenNotExactVersion_ThrowsException(string version, string expected = null)
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var project = new MockMSBuildProject(testDirectory)
                {
                    Items = new Dictionary <string, IList <IMSBuildItem> >
                    {
                        ["PackageDownload"] = new List <IMSBuildItem>
                        {
                            new MSBuildItem("PackageA", new Dictionary <string, string> {
                                ["Version"] = version
                            }),
                        }
                    }
                };

                Action act = () =>
                {
                    var _ = MSBuildStaticGraphRestore.GetPackageDownloads(project).ToList();
                };

                act.ShouldThrow <ArgumentException>().WithMessage($"'{expected ?? VersionRange.Parse(version).OriginalString}' is not an exact version like '[1.0.0]'. Only exact versions are allowed with PackageDownload.");
            }
        }
        public void GetPackageDownloads_WhenDuplicatesExist_DuplicatesIgnored()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var project = new MockMSBuildProject(testDirectory)
                {
                    Items = new Dictionary <string, IList <IMSBuildItem> >
                    {
                        ["PackageDownload"] = new List <IMSBuildItem>
                        {
                            new MSBuildItem("PackageA", new Dictionary <string, string> {
                                ["Version"] = "[1.1.1]"
                            }),
                            new MSBuildItem("PackageA", new Dictionary <string, string> {
                                ["Version"] = "[2.0.0]"
                            }),
                            new MSBuildItem("PackageB", new Dictionary <string, string> {
                                ["Version"] = "[1.2.3];[4.5.6]"
                            }),
                        }
                    }
                };

                var actual = MSBuildStaticGraphRestore.GetPackageDownloads(project);

                actual.ShouldBeEquivalentTo(new List <DownloadDependency>
                {
                    new DownloadDependency("PackageA", VersionRange.Parse("[1.1.1]")),
                    new DownloadDependency("PackageB", VersionRange.Parse("[1.2.3]")),
                    new DownloadDependency("PackageB", VersionRange.Parse("[4.5.6]")),
                });
            }
        }