Ejemplo n.º 1
0
        public void Workspace_TryGetServerItemForLocalItem_PassValidItem()
        {
            string serverItem = String.Format("$/{0}", Environment.GetEnvironmentVariable("TFS_PROJECT"));
            string item1      = String.Format("{0}/foo.txt", serverItem);
            string item2      = workspace.TryGetServerItemForLocalItem(Path.Combine(Environment.CurrentDirectory, "foo.txt"));

            Assert.AreEqual(item1, item2);
        }
Ejemplo n.º 2
0
        public void Execute(TeamFoundationWorkspace ws)
        {
            if (ws == null)
            {
                AppOutput.ConsoleWriteLine("---- Invalide ws config");
            }

            var files = GetLocalFiles();

            AppOutput.ConsoleWriteLine("Tfs inclider: filesFound: " + files.Count());

            var paddingChanges = ws.GetPendingChanges().Select(p => p.LocalItem);

            foreach (var file in files)
            {
                var serverPath       = ws.TryGetServerItemForLocalItem(file);
                var serverItemExists = ws.VersionControlServer.ServerItemExists(serverPath, ItemType.File);
                if (!serverItemExists && !paddingChanges.Contains(file))
                {
                    ws.PendAdd(file);
                    AppOutput.ConsoleWriteLine("    Exluded file: " + file);
                }
            }

            AppOutput.ConsoleWriteLine("Finished");
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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();
        }