public void Workspace_GetViaInfo() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[1]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); //Workstation.Current.UpdateWorkspaceInfoCache(vcs, Environment.GetEnvironmentVariable("TFS_USERNAME")); WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); Workspace w2 = info.GetWorkspace(tfs); // does info.GetWorkspace talk to the server and get the // mapped paths or no? ANSWER: NO IT DOESN'T string serverItem2 = w2.TryGetServerItemForLocalItem("foo.txt"); Assert.AreEqual(null, serverItem2); w1.Delete(); }
public void Workspace_Get() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[1]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); Workspace w2 = vcs.GetWorkspace("CreateDelete1_Workspace"); Assert.AreEqual("My Comment", w2.Comment); w1.Delete(); }
public void Workspace_RefreshMappings2() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[1]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); //Workstation.Current.UpdateWorkspaceInfoCache(vcs, Environment.GetEnvironmentVariable("TFS_USERNAME")); WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); Workspace w2 = info.GetWorkspace(tfs); // this will talk to the server and get the mapped paths // BUT it will fail because we don't pass a full path like in RefreshMappings1 w2.RefreshMappings(); string serverItem2 = w2.TryGetServerItemForLocalItem("foo.txt"); Assert.IsNull(serverItem2); w1.Delete(); }
public bool AddToTFVC(string[] _files, WorkItem _wi, Workspace _ws) { try { _ws.Get(); // Now add everything. _ws.PendAdd(_files, false); WorkItemCheckinInfo[] _wici = new WorkItemCheckinInfo[1]; _wici[0] = new WorkItemCheckinInfo(_wi, WorkItemCheckinAction.Associate); if (_ws.CheckIn(_ws.GetPendingChanges(), null, null, _wici, null) > 0) { _ws.Delete(); return true; } else { return false; } } catch { return false; } }
public void Workspace_CreateDelete1() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME")); w1.Delete(); }
public void Workspace_TryGetWorkingFolderForServerItem() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) { return; } TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); WorkingFolder[] folders = new WorkingFolder[2]; string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT")); folders[0] = new WorkingFolder(serverItem, Environment.CurrentDirectory); string deeper = Path.Combine(Environment.CurrentDirectory, "deeper"); folders[1] = new WorkingFolder(serverItem + "/deeper", deeper); Workspace w1 = vcs.CreateWorkspace("CreateDelete1_Workspace", Environment.GetEnvironmentVariable("TFS_USERNAME"), "My Comment", folders, Environment.MachineName); WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); Workspace w2 = info.GetWorkspace(tfs); // this will talk to the server and get the mapped paths w2.RefreshMappings(); { string serverItem1 = String.Format("{0}/deeper/foo.txt", serverItem); WorkingFolder folder = w2.TryGetWorkingFolderForServerItem(serverItem1); Assert.AreEqual(deeper, folder.LocalItem); } { string serverItem1 = String.Format("junk/deeper/foo.txt", serverItem); WorkingFolder folder = w2.TryGetWorkingFolderForServerItem(serverItem1); Assert.IsNull(deeper); } w1.Delete(); }
public void FixtureTearDown() { workspace.Delete(); }
public void FixtureTearDown() { workspace.Delete(); // clear out test workspace from cache Workstation.Current.UpdateWorkspaceInfoCache(versionControlServer, Environment.GetEnvironmentVariable("TFS_USERNAME")); }