예제 #1
0
        public void OneFromUnspecifiedIsEmpty()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            t.Exclude = new ITaskItem[] { new TaskItem("MyFile.txt") };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.Include.Length);
        }
		public void TestAssignment ()
		{
			CreateItem ci = new CreateItem ();

			ci.AdditionalMetadata = new string [1] { "a=1" };
			ci.Include = new ITaskItem [1] { new TaskItem ("1") };
			ci.Exclude = new ITaskItem [1] { new TaskItem ("2") };

			Assert.AreEqual ("a=1", ci.AdditionalMetadata [0], "A1");
			Assert.AreEqual ("1", ci.Include [0].ItemSpec, "A2");
			Assert.AreEqual ("2", ci.Exclude [0].ItemSpec, "A3");
		}
예제 #3
0
        public void UnspecifiedFromOneIsOne()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            t.Include = new ITaskItem[] { new TaskItem("MyFile.txt") };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(1, t.Include.Length);
            Assert.Equal(t.Include[0].ItemSpec, t.Include[0].ItemSpec);
        }
예제 #4
0
        public void OneFromOneIsZero()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            t.Include = new ITaskItem[] { new TaskItem("MyFile.txt") };
            t.Exclude = new ITaskItem[] { new TaskItem("MyFile.txt") };

            bool success = t.Execute();

            Assert.IsTrue(success);
            Assert.AreEqual(0, t.Include.Length);
        }
예제 #5
0
        public void OneFromOneMismatchIsOne()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            t.Include = new ITaskItem[] { new TaskItem("MyFile.txt") };
            t.Exclude = new ITaskItem[] { new TaskItem("MyFileOther.txt") };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(1, t.Include.Length);
            Assert.Equal("MyFile.txt", t.Include[0].ItemSpec);
        }
예제 #6
0
        public void UnspecifiedFromUnspecifiedIsEmpty()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.Include.Length);
        }
예제 #7
0
        public void AdditionalMetaDataOverwriteExisting()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            TaskItem item = new TaskItem("MyFile.txt");
            item.SetMetadata("MyMetaData", "SomePreserveMeValue");

            t.Include = new ITaskItem[] { item };

            // The default for CreateItem is to overwrite any existing metadata
            // t.PreserveExistingMetadata = false;

            t.AdditionalMetadata = new string[] { "MyMetaData=SomeOverwriteValue" };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal("SomeOverwriteValue", t.Include[0].GetMetadata("MyMetaData"));
        }
예제 #8
0
        public void AdditionalMetaData()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            t.Include = new ITaskItem[] { new TaskItem("MyFile.txt") };
            t.AdditionalMetadata = new string[] { "MyMetaData=SomeValue" };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal("SomeValue", t.Include[0].GetMetadata("MyMetaData"));
        }
예제 #9
0
        public void CaseDoesntMatter()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            t.Include = new ITaskItem[] { new TaskItem("MyFile.txt") };
            t.Exclude = new ITaskItem[] { new TaskItem("myfile.tXt") };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal(0, t.Include.Length);
        }
예제 #10
0
        /// <summary>
        /// Prepares the 'SourceFiles', etc., <see cref="TaskItem"/> data.
        /// </summary>
        /// <param name="task">The task to prepare.</param>
        /// <remarks>
        /// This is experimental. Uncommenting the "cr.Execute()" line below, fills the
        /// SourceFiles property of a Backup-Task in the editor with the evaluated path data. 
        /// A <see cref="CreateItem"/> task is used to mimic the work of a project build engine.
        /// </remarks>
        private void PrepareTask(ITask task)
        {
            // Todo: put this task generation extra.
            /*for (int index = 0; index < this.Paths.Count; index++)
            {
                var item = this.Paths[index];
            }*/
            // int xasd = 0;
            var result = this.Paths.Select(
                e =>
                {
                    var cr = new CreateItem();
                    if (e.Inclusion.Count > 0)
                    {
                        cr.Include = e.Inclusion.Select(
                            t =>
                            {
                                if (e.Path.EndsWith("\\"))
                                {
                                    return new TaskItem(e.Path + t.Pattern);
                                }
                                else
                                {
                                    return new TaskItem(e.Path + "\\" + t.Pattern);
                                }
                            }

                            ).ToArray();
                    }
                    else
                    {
                        ITaskItem taskItem;
                        var finfo = new FileInfo(e.Path);
                        if (Directory.Exists(e.Path))
                        {
                            // a directory
                            taskItem = new TaskItem(e.Path + "\\" + recursivePattern);
                        }
                        else
                        {
                            // a file
                            taskItem = new TaskItem(e.Path);
                        }

                        cr.Include = new[] { taskItem };
                    }

                    cr.Exclude =
                        e.Exclusion.Select((t) => { return new TaskItem(e.Path + "\\" + t.Pattern); }).ToArray();

                    // at the moment, do not execute the items.
                    // cr.Execute();
                    return cr;
                }

                );

            if (task is Backup)
            {
                var btask = (Backup)task;

                // var res = result.ToArray();
                var includes = result.SelectMany((e) => e.Include);
                btask.SourceFiles = includes.ToArray();

                // btask.DestinationFolder = new TaskItem(@"C:\tmp\%(RecursiveDir)");
                // var itemsByType = new Hashtable();
                // foreach (var item in btask.SourceFiles)
                // {
                // itemsByType.Add(
                // }
                // var bla = ItemExpander.ItemizeItemVector(@"@(File)", null, itemsByType);
                // Todo: do i need the build engine ?
                // btask.BuildEngine = this.BuildEngine;
            }
        }
예제 #11
0
        public void AdditionalMetaDataPreserveExisting()
        {
            CreateItem t = new CreateItem();
            t.BuildEngine = new MockEngine();

            TaskItem item = new TaskItem("MyFile.txt");
            item.SetMetadata("MyMetaData", "SomePreserveMeValue");

            t.Include = new ITaskItem[] { item };
            t.PreserveExistingMetadata = true;

            t.AdditionalMetadata = new string[] { "MyMetaData=SomeValue" };

            bool success = t.Execute();

            Assert.IsTrue(success);
            Assert.AreEqual("SomePreserveMeValue", t.Include[0].GetMetadata("MyMetaData"));
        }