public void Execute_AllowMultiRangeVersion()
        {
            // Arrange
            var task = new GetRestorePackageDownloadsTask()
            {
                BuildEngine       = new TestBuildEngine(),
                ProjectUniqueName = "MyProj",
                TargetFrameworks  = "netstandard2.0",
                PackageDownloads  = new ITaskItem[]
                {
                    new MockTaskItem("x")
                    {
                        ["Version"] = "[1.0.0];[2.0.0]"
                    }
                }
            };

            // Act
            var result = task.Execute();

            // Assert
            Assert.True(result, "Task failed");
            Assert.Equal(1, task.RestoreGraphItems.Length);
            Assert.Equal("x", task.RestoreGraphItems[0].GetMetadata("Id"));
            Assert.Equal("[1.0.0];[2.0.0]", task.RestoreGraphItems[0].GetMetadata("VersionRange"));
        }
        public void Execute_AllowMultiRangeVersion()
        {
            // Arrange
            var buildEngine = new TestBuildEngine();

            var packageX = new TaskItem();

            packageX.ItemSpec = "x";
            packageX.SetMetadata("Version", "[1.0.0];[2.0.0]");

            var packageDownloads = new List <ITaskItem>()
            {
                packageX
            };

            var task = new GetRestorePackageDownloadsTask()
            {
                BuildEngine       = buildEngine,
                ProjectUniqueName = "MyProj",
                TargetFrameworks  = "netstandard2.0",
                PackageDownloads  = packageDownloads.ToArray()
            };

            // Act
            var result = task.Execute();

            // Assert
            Assert.True(result, "Task failed");
            Assert.Equal(1, task.RestoreGraphItems.Length);
            Assert.Equal("x", task.RestoreGraphItems[0].GetMetadata("Id"));
            Assert.Equal("[1.0.0];[2.0.0]", task.RestoreGraphItems[0].GetMetadata("VersionRange"));
        }
        public void Execute_AllowMultiplePackages()
        {
            // Arrange
            var buildEngine = new TestBuildEngine();

            var packageX = new TaskItem();

            packageX.ItemSpec = "x";
            packageX.SetMetadata("Version", "[1.0.0]");

            var packageY = new TaskItem();

            packageY.ItemSpec = "y";
            packageY.SetMetadata("Version", "[2.0.0]");

            var packageDownloads = new List <ITaskItem>()
            {
                packageX,
                packageY
            };

            var task = new GetRestorePackageDownloadsTask()
            {
                BuildEngine       = buildEngine,
                ProjectUniqueName = "MyProj",
                TargetFrameworks  = "netstandard2.0",
                PackageDownloads  = packageDownloads.ToArray()
            };

            // Act
            var result = task.Execute();

            // Assert
            Assert.True(result, "Task failed");
            Assert.Equal(2, task.RestoreGraphItems.Length);

            var package = task.RestoreGraphItems.SingleOrDefault(i => i.GetMetadata("Id") == "x");

            Assert.NotNull(package);
            Assert.Equal("[1.0.0]", package.GetMetadata("VersionRange"));

            package = task.RestoreGraphItems.SingleOrDefault(i => i.GetMetadata("Id") == "y");
            Assert.NotNull(package);
            Assert.Equal("[2.0.0]", package.GetMetadata("VersionRange"));
        }
        public void Execute_AllowMultiplePackages()
        {
            // Arrange
            var task = new GetRestorePackageDownloadsTask()
            {
                BuildEngine       = new TestBuildEngine(),
                ProjectUniqueName = "MyProj",
                TargetFrameworks  = "netstandard2.0",
                PackageDownloads  = new ITaskItem[]
                {
                    new MockTaskItem("x")
                    {
                        ["Version"] = "[1.0.0]"
                    },
                    new MockTaskItem("y")
                    {
                        ["Version"] = "[2.0.0]"
                    }
                }
            };

            // Act
            var result = task.Execute();

            // Assert
            Assert.True(result, "Task failed");
            Assert.Equal(2, task.RestoreGraphItems.Length);

            var package = task.RestoreGraphItems.SingleOrDefault(i => i.GetMetadata("Id") == "x");

            Assert.NotNull(package);
            Assert.Equal("[1.0.0]", package.GetMetadata("VersionRange"));

            package = task.RestoreGraphItems.SingleOrDefault(i => i.GetMetadata("Id") == "y");
            Assert.NotNull(package);
            Assert.Equal("[2.0.0]", package.GetMetadata("VersionRange"));
        }