public void Setup() { //create base folder for "project"'s local copy _workingFolder = Path.Combine(Path.GetTempPath(), "FROM_VSS_DELETE"); Directory.CreateDirectory(_workingFolder); //This item represents the base project item _project = new MockVssItem(); _project.Name = "TEMPVSSPROJECT"; _project.SetType((int)VSSItemType.VSSITEM_PROJECT); string localProjectPath = _workingFolder; Directory.CreateDirectory(localProjectPath); //create the instance of the DeleteTask that we will use in the tests _deleteTask = new DeleteTask(); _deleteTask.Item = _project; _deleteTask.Path = "$/" + _project.Name; //make the DeleteTask happy by giving it a dummy project file to reference XmlDocument doc = new XmlDocument(); doc.LoadXml("<project name='test'/>"); _deleteTask.Project = new Project(doc, Level.Info, 0); }
public void BuildDeletedTableDoesNotIncludeMultiplyRestoredItemsOdd() { MockVssItem restored = new MockVssItem(); restored.Name = "restored"; restored.Deleted = false; MockVssItem restored2 = new MockVssItem(); restored2.Name = "restored"; restored2.Deleted = true; MockVssItem restored3 = new MockVssItem(); restored3.Name = "restored"; restored3.Deleted = true; MockVssItem restored4 = new MockVssItem(); restored4.Name = "restored"; restored4.Deleted = true; MockVssItems items = new MockVssItems(); items.Add(restored); //order doesn't matter items.Add(restored2); items.Add(restored3); items.Add(restored4); Hashtable table = _getTask.BuildDeletedTable(items); Assert.AreEqual(1, table.Count, "items have the same name, should only be one record"); Assert.IsFalse((bool)table[restored.Name], "restored items should not be deleted"); }
public void BuildDeletedTableDoesNotIncludeRegularItems() { MockVssItem regular = new MockVssItem(); regular.Name = "regular"; regular.Deleted = false; MockVssItems items = new MockVssItems(); items.Add(regular); Hashtable table = _getTask.BuildDeletedTable(items); Assert.IsFalse((bool)table[regular.Name], "regular items should not be deleted"); }
public void BuildDeletedTableDoesIncludeDeletedItems() { MockVssItem deleted = new MockVssItem(); deleted.Name = "deleted"; deleted.Deleted = true; MockVssItems items = new MockVssItems(); items.Add(deleted); Hashtable table = _getTask.BuildDeletedTable(items); Assert.IsTrue((bool)table[deleted.Name], "deleted items should be deleted"); }
public void Setup() { //create base folder for "project"'s local copy _workingFolder = Path.Combine(Path.GetTempPath(), "FROM_VSS_DELETE"); Directory.CreateDirectory(_workingFolder); //This item represents the base project item _project = new MockVssItem(); _project.Name = "TEMPVSSPROJECT"; _project.SetType((int) VSSItemType.VSSITEM_PROJECT); string localProjectPath = _workingFolder; Directory.CreateDirectory(localProjectPath); //create the instance of the DeleteTask that we will use in the tests _deleteTask = new DeleteTask(); _deleteTask.Item = _project; _deleteTask.Path = "$/" + _project.Name; //make the DeleteTask happy by giving it a dummy project file to reference XmlDocument doc = new XmlDocument(); doc.LoadXml("<project name='test'/>"); _deleteTask.Project = new Project(doc, Level.Info, 0); }
public void BuildDeletedTableDoesNotIncludeRestoredItemsWithDifferentCaseNames() { MockVssItem restored = new MockVssItem(); restored.Name = "restored"; restored.Deleted = false; MockVssItem restored2 = new MockVssItem(); restored2.Name = "Restored"; restored2.Deleted = true; MockVssItems items = new MockVssItems(); items.Add(restored); items.Add(restored2); //order doesn't matter Hashtable table = _getTask.BuildDeletedTable(items); Assert.AreEqual(1, table.Count, "items having names with case differences only are the same"); Assert.IsFalse((bool)table[restored.Name], "restored items should not be deleted"); Assert.IsFalse((bool)table[restored2.Name], "restored items should not be deleted"); }
public void Setup() { //create base folder for "project"'s local copy _workingFolder = Path.Combine(Path.GetTempPath(), "FROM_VSS"); Directory.CreateDirectory(_workingFolder); //This item represents the base project item _project = new MockVssItem(); _project.Name = "TEMPVSSPROJECT"; _project.SetType((int)VSSItemType.VSSITEM_PROJECT); string localProjectPath = _workingFolder; Directory.CreateDirectory(localProjectPath); //a normal file item whose local copy is in the project's local folder; _normalItem = new MockVssItem(); _normalItem.Name = "normalItem.txt"; _normalItem.SetType((int)VSSItemType.VSSITEM_FILE); _normalItem.Deleted = false; _localNormalItemPath = Path.Combine(localProjectPath, _normalItem.Name); StreamWriter s = File.CreateText(_localNormalItemPath); s.Close(); //a deleted file item that represents an earlier, deleted version of the normal file item _normalItemDeleted = new MockVssItem(); _normalItemDeleted.Name = "normalItem.txt"; _normalItemDeleted.SetType((int)VSSItemType.VSSITEM_FILE); _normalItemDeleted.Deleted = true; //a deleted file item whose local copy is located under the base project's local folder _item = new MockVssItem(); _item.Name = "tempVSSItem.txt"; _item.SetType((int)VSSItemType.VSSITEM_FILE); _item.Deleted = true; _localItemPath = Path.Combine(localProjectPath, _item.Name); s = File.CreateText(_localItemPath); s.Close(); //a deleted file item with *no* local copy _alreadyGoneItem = new MockVssItem(); _alreadyGoneItem.Name = "notthere.txt"; _alreadyGoneItem.SetType((int)VSSItemType.VSSITEM_FILE); _alreadyGoneItem.Deleted = true; //a deleted file item whose local copy is located under the base project's local folder and read-only _readOnlyItem = new MockVssItem(); _readOnlyItem.Name = "readOnlyTempVSSItem.txt"; _readOnlyItem.SetType((int)VSSItemType.VSSITEM_FILE); _readOnlyItem.Deleted = true; _localReadOnlyItemPath = Path.Combine(localProjectPath, _readOnlyItem.Name); s = File.CreateText(_localReadOnlyItemPath); s.Close(); File.SetAttributes(_localReadOnlyItemPath, FileAttributes.ReadOnly); //a deleted project item whose local copy is located under the base project's local folder and read-only _readOnlySubProject = new MockVssItem(); _readOnlySubProject.Name = "READONLYSUBPROJECT"; _readOnlySubProject.SetType((int)VSSItemType.VSSITEM_PROJECT); _readOnlySubProject.Deleted = true; _localReadOnlySubProjectPath = Path.Combine(localProjectPath, _readOnlySubProject.Name); Directory.CreateDirectory(_localReadOnlySubProjectPath); File.SetAttributes(_localReadOnlySubProjectPath, FileAttributes.ReadOnly); //a deleted file item whose local copy is located under the read-only sub project's local folder //is itself read-only _readOnlySubItem = new MockVssItem(); _readOnlySubItem.Name = "readOnlySubItem.txt"; _readOnlySubItem.SetType((int)VSSItemType.VSSITEM_FILE); _readOnlySubItem.Deleted = true; _localReadOnlySubItemPath = Path.Combine(_localReadOnlySubProjectPath, _readOnlySubItem.Name); s = File.CreateText(_localReadOnlySubItemPath); s.Close(); File.SetAttributes(_localReadOnlySubItemPath, FileAttributes.ReadOnly); //a deleted project item whose local copy is in the base project's local folder _subProject = new MockVssItem(); _subProject.Name = "SUBPROJECT"; _subProject.SetType((int)VSSItemType.VSSITEM_PROJECT); _subProject.Deleted = true; _localSubProjectPath = Path.Combine(localProjectPath, _subProject.Name); Directory.CreateDirectory(_localSubProjectPath); //a deleted file item whose local copy is in the sub-project's local folder _subItem = new MockVssItem(); _subItem.Name = "tempVSSSubItem.txt"; _subItem.SetType((int)VSSItemType.VSSITEM_FILE); _subItem.Deleted = true; _localSubItemPath = Path.Combine(_localSubProjectPath, _subItem.Name); s = File.CreateText(_localSubItemPath); s.Close(); //add the sub file item to the sub project's items collection MockVssItems items = new MockVssItems(); items.Add(_subItem); _subProject.SetItems(items); //add the read-only sub file item to read-only sub-project's items collection items = new MockVssItems(); items.Add(_readOnlySubItem); _readOnlySubProject.SetItems(items); //create the instance of the GetTask that we will use in the tests _getTask = new GetTask(); _getTask.Item = _project; _getTask.LocalPath = new DirectoryInfo(_workingFolder); _getTask.RemoveDeleted = true; //make the GetTask happy by giving it a dummy project file to reference XmlDocument doc = new XmlDocument(); doc.LoadXml("<project name='test'/>"); _getTask.Project = new Project(doc, Level.Info, 0); }
public void Setup() { //create base folder for "project"'s local copy _workingFolder = Path.Combine(Path.GetTempPath(), "FROM_VSS"); Directory.CreateDirectory(_workingFolder); //This item represents the base project item _project = new MockVssItem(); _project.Name = "TEMPVSSPROJECT"; _project.SetType((int) VSSItemType.VSSITEM_PROJECT); string localProjectPath = _workingFolder; Directory.CreateDirectory(localProjectPath); //a normal file item whose local copy is in the project's local folder; _normalItem = new MockVssItem(); _normalItem.Name = "normalItem.txt"; _normalItem.SetType((int) VSSItemType.VSSITEM_FILE); _normalItem.Deleted = false; _localNormalItemPath = Path.Combine(localProjectPath, _normalItem.Name); StreamWriter s = File.CreateText(_localNormalItemPath); s.Close(); //a deleted file item that represents an earlier, deleted version of the normal file item _normalItemDeleted = new MockVssItem(); _normalItemDeleted.Name = "normalItem.txt"; _normalItemDeleted.SetType((int) VSSItemType.VSSITEM_FILE); _normalItemDeleted.Deleted = true; //a deleted file item whose local copy is located under the base project's local folder _item = new MockVssItem(); _item.Name = "tempVSSItem.txt"; _item.SetType((int) VSSItemType.VSSITEM_FILE); _item.Deleted = true; _localItemPath = Path.Combine(localProjectPath, _item.Name); s = File.CreateText(_localItemPath); s.Close(); //a deleted file item with *no* local copy _alreadyGoneItem = new MockVssItem(); _alreadyGoneItem.Name = "notthere.txt"; _alreadyGoneItem.SetType((int) VSSItemType.VSSITEM_FILE); _alreadyGoneItem.Deleted = true; //a deleted file item whose local copy is located under the base project's local folder and read-only _readOnlyItem = new MockVssItem(); _readOnlyItem.Name = "readOnlyTempVSSItem.txt"; _readOnlyItem.SetType((int) VSSItemType.VSSITEM_FILE); _readOnlyItem.Deleted = true; _localReadOnlyItemPath = Path.Combine(localProjectPath, _readOnlyItem.Name); s = File.CreateText(_localReadOnlyItemPath); s.Close(); File.SetAttributes(_localReadOnlyItemPath, FileAttributes.ReadOnly); //a deleted project item whose local copy is located under the base project's local folder and read-only _readOnlySubProject = new MockVssItem(); _readOnlySubProject.Name = "READONLYSUBPROJECT"; _readOnlySubProject.SetType((int) VSSItemType.VSSITEM_PROJECT); _readOnlySubProject.Deleted = true; _localReadOnlySubProjectPath = Path.Combine(localProjectPath, _readOnlySubProject.Name); Directory.CreateDirectory(_localReadOnlySubProjectPath); File.SetAttributes(_localReadOnlySubProjectPath, FileAttributes.ReadOnly); //a deleted file item whose local copy is located under the read-only sub project's local folder //is itself read-only _readOnlySubItem = new MockVssItem(); _readOnlySubItem.Name = "readOnlySubItem.txt"; _readOnlySubItem.SetType((int) VSSItemType.VSSITEM_FILE); _readOnlySubItem.Deleted = true; _localReadOnlySubItemPath = Path.Combine(_localReadOnlySubProjectPath, _readOnlySubItem.Name); s = File.CreateText(_localReadOnlySubItemPath); s.Close(); File.SetAttributes(_localReadOnlySubItemPath, FileAttributes.ReadOnly); //a deleted project item whose local copy is in the base project's local folder _subProject = new MockVssItem(); _subProject.Name = "SUBPROJECT"; _subProject.SetType((int) VSSItemType.VSSITEM_PROJECT); _subProject.Deleted = true; _localSubProjectPath = Path.Combine(localProjectPath, _subProject.Name); Directory.CreateDirectory(_localSubProjectPath); //a deleted file item whose local copy is in the sub-project's local folder _subItem = new MockVssItem(); _subItem.Name = "tempVSSSubItem.txt"; _subItem.SetType((int) VSSItemType.VSSITEM_FILE); _subItem.Deleted = true; _localSubItemPath = Path.Combine(_localSubProjectPath, _subItem.Name); s = File.CreateText(_localSubItemPath); s.Close(); //add the sub file item to the sub project's items collection MockVssItems items = new MockVssItems(); items.Add(_subItem); _subProject.SetItems(items); //add the read-only sub file item to read-only sub-project's items collection items = new MockVssItems(); items.Add(_readOnlySubItem); _readOnlySubProject.SetItems(items); //create the instance of the GetTask that we will use in the tests _getTask = new GetTask(); _getTask.Item = _project; _getTask.LocalPath = new DirectoryInfo(_workingFolder); _getTask.RemoveDeleted = true; //make the GetTask happy by giving it a dummy project file to reference XmlDocument doc = new XmlDocument(); doc.LoadXml("<project name='test'/>"); _getTask.Project = new Project(doc, Level.Info, 0); }
public void BuildDeletedTableDoesNotIncludeRestoredItemsWithDifferentCaseNames() { MockVssItem restored = new MockVssItem(); restored.Name = "restored"; restored.Deleted = false; MockVssItem restored2 = new MockVssItem(); restored2.Name = "Restored"; restored2.Deleted = true; MockVssItems items = new MockVssItems(); items.Add(restored); items.Add(restored2); //order doesn't matter Hashtable table = _getTask.BuildDeletedTable(items); Assert.AreEqual(1, table.Count, "items having names with case differences only are the same"); Assert.IsFalse((bool) table[restored.Name], "restored items should not be deleted"); Assert.IsFalse((bool) table[restored2.Name], "restored items should not be deleted"); }
public void BuildDeletedTableDoesNotIncludeMultiplyRestoredItemsEven() { MockVssItem restored = new MockVssItem(); restored.Name = "restored"; restored.Deleted = false; MockVssItem restored2 = new MockVssItem(); restored2.Name = "restored"; restored2.Deleted = true; MockVssItem restored3 = new MockVssItem(); restored3.Name = "restored"; restored3.Deleted = true; MockVssItem restored4 = new MockVssItem(); restored4.Name = "restored"; restored4.Deleted = true; MockVssItem restored5 = new MockVssItem(); restored5.Name = "restored"; restored5.Deleted = true; MockVssItems items = new MockVssItems(); items.Add(restored); //order doesn't matter items.Add(restored2); items.Add(restored3); items.Add(restored4); items.Add(restored5); Hashtable table = _getTask.BuildDeletedTable(items); Assert.AreEqual(1, table.Count, "items have the same name, should only be one record"); Assert.IsFalse((bool) table[restored.Name], "restored items should not be deleted"); }
public void BuildDeletedTableDoesNotIncludeRegularItems() { MockVssItem regular = new MockVssItem(); regular.Name = "regular"; regular.Deleted = false; MockVssItems items = new MockVssItems(); items.Add(regular); Hashtable table = _getTask.BuildDeletedTable(items); Assert.IsFalse((bool) table[regular.Name], "regular items should not be deleted"); }
public void BuildDeletedTableDoesIncludeDeletedItems() { MockVssItem deleted = new MockVssItem(); deleted.Name = "deleted"; deleted.Deleted = true; MockVssItems items = new MockVssItems(); items.Add(deleted); Hashtable table = _getTask.BuildDeletedTable(items); Assert.IsTrue((bool) table[deleted.Name], "deleted items should be deleted"); }