public void NoItems()
        {
            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.OutputItems.Length);
        }
        public void InvalidItemPath()
        {
            ITaskItem item = GetParentedTaskItem();
            item.ItemSpec = "|||";

            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            t.Items = new ITaskItem[] { new TaskItem(item) };
            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.OutputItems.Length);
        }
        public void Basic()
        {
            ITaskItem item = GetParentedTaskItem();

            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            t.Items = new ITaskItem[] { new TaskItem(item) };
            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(1, t.OutputItems.Length);
            Assert.Equal(item.ItemSpec, t.OutputItems[0].ItemSpec);

            // Link metadata should have been added by the task, and OriginalItemSpec was added by the copy 
            Assert.Equal(item.MetadataCount + 2, t.OutputItems[0].MetadataCount);
            Assert.Equal(@"SubFolder\a.cs", t.OutputItems[0].GetMetadata("Link"));
        }
        public void InvalidItemPathWithOtherValidItem()
        {
            ITaskItem item1 = GetParentedTaskItem(itemSpec: "|||");
            ITaskItem item2 = GetParentedTaskItem();

            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            t.Items = new ITaskItem[] { new TaskItem(item1), new TaskItem(item2) };
            bool success = t.Execute();

            Assert.IsTrue(success);
            Assert.AreEqual(1, t.OutputItems.Length);
            Assert.AreEqual(item2.ItemSpec, t.OutputItems[0].ItemSpec);

            // Link metadata should have been added by the task, and OriginalItemSpec was added by the copy 
            Assert.AreEqual(item2.MetadataCount + 2, t.OutputItems[0].MetadataCount);
            Assert.AreEqual(@"SubFolder\a.cs", t.OutputItems[0].GetMetadata("Link"));
        }
        public void NoDefiningProjectMetadata()
        {
            ITaskItem item = new TaskItem(@"SubFolder\a.cs");

            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            t.Items = new ITaskItem[] { item };
            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.OutputItems.Length);
        }
        public void OutsideDefiningProjectCone()
        {
            ITaskItem item = GetParentedTaskItem(itemSpec: @"c:\subfolder\a.cs");

            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            t.Items = new ITaskItem[] { new TaskItem(item) };
            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.OutputItems.Length);
        }
        public void DontOverrideLink()
        {
            ITaskItem item = GetParentedTaskItem(linkMetadata: @"SubFolder2\SubSubFolder\a.cs");

            AssignLinkMetadata t = new AssignLinkMetadata();
            t.BuildEngine = new MockEngine();
            t.Items = new ITaskItem[] { new TaskItem(item) };
            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.OutputItems.Length);
        }