Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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 Workspace GetWorkspace(WorkspaceInfo workspaceInfo, TfsTeamProjectCollection tfsTeamProjectCollection)
        {
            this.Logger().Trace("GetWorkspace  ProjectCollection: {0} Workspace: {1}", tfsTeamProjectCollection.Name, workspaceInfo.Name);

            return workspaceInfo.GetWorkspace(tfsTeamProjectCollection);
        }