public void NotFound() { FindAppConfigFile f = new FindAppConfigFile(); f.BuildEngine = new MockEngine(); f.PrimaryList = new ITaskItem[] { new TaskItem("yyy"), new TaskItem("xxx") }; f.SecondaryList = new ITaskItem[] { new TaskItem("iii"), new TaskItem("xxx") }; f.TargetPath = "targetpath"; Assert.True(f.Execute()); Assert.Equal(null, f.AppConfigFile); }
public void MatchFileNameOnlyWithAnInvalidPath() { FindAppConfigFile f = new FindAppConfigFile(); f.BuildEngine = new MockEngine(); f.PrimaryList = new ITaskItem[] { new TaskItem("yyy"), new TaskItem("xxx") }; f.SecondaryList = new ITaskItem[] { new TaskItem("|||"), new TaskItem(@"foo\\app.config"), new TaskItem(@"!@#$@$%|"), new TaskItem("uuu") }; f.TargetPath = "targetpath"; Assert.True(f.Execute()); // Should ignore the invalid paths Assert.Equal(@"foo\\app.config", f.AppConfigFile.ItemSpec); }
public void FoundInSecondBelowProjectDirectory() { FindAppConfigFile f = new FindAppConfigFile(); f.BuildEngine = new MockEngine(); f.PrimaryList = new ITaskItem[] { new TaskItem("yyy"), new TaskItem("xxx") }; f.SecondaryList = new ITaskItem[] { new TaskItem("foo\\app.config"), new TaskItem("xxx") }; f.TargetPath = "targetpath"; Assert.True(f.Execute()); Assert.Equal("foo\\app.config", f.AppConfigFile.ItemSpec); Assert.Equal("targetpath", f.AppConfigFile.GetMetadata("TargetPath")); }
public void ReturnsLastOne() { FindAppConfigFile f = new FindAppConfigFile(); f.BuildEngine = new MockEngine(); ITaskItem item1 = new TaskItem("app.config"); item1.SetMetadata("id", "1"); ITaskItem item2 = new TaskItem("app.config"); item2.SetMetadata("id", "2"); f.PrimaryList = new ITaskItem[] { item1, item2 }; f.SecondaryList = new ITaskItem[] { }; f.TargetPath = "targetpath"; Assert.True(f.Execute()); Assert.Equal("app.config", f.AppConfigFile.ItemSpec); Assert.Equal(item2.GetMetadata("id"), f.AppConfigFile.GetMetadata("id")); }