Esempio n. 1
0
        public void CreateTeamProject_PassInTestProjectDetailsWithExistingProjectName_ArgumentExceptionThrown()
        {
            // arrange
            ITeamProjects teamProjects = TeamProjectFactory.CreateTeamProjectMananger(TestConstants.TfsCollectionUri);
            string        projectName  = TestConstants.TfsTeamProjectName;

            IProcessTemplates processTemplates    = ProcessTemplateFactory.CreateProcessTemplateMananger(TestConstants.TfsCollectionUri);
            string            processTemplateName = processTemplates.ListProcessTemplates()[0].Name;

            // act
            teamProjects.CreateTeamProject(projectName, projectName + " Description", processTemplateName, false, false);

            // assert
            bool actual = false;

            foreach (string project in teamProjects.ListTeamProjectNames())
            {
                if (string.Compare(project, projectName, true) == 0)
                {
                    actual = true;
                    break;
                }
            }

            Assert.IsTrue(actual);
        }
Esempio n. 2
0
        public void ListProcessTemplates_Defaults_ListGreaterThan0()
        {
            // arrange
            IProcessTemplates processTemplates = ProcessTemplateFactory.CreateProcessTemplateMananger(TestConstants.TfsCollectionUri);

            // act
            List <ProcessTemplate> actual = processTemplates.ListProcessTemplates();

            // assert
            Assert.IsNotNull(actual);

            Assert.IsTrue(actual.Count > 0);
        }
Esempio n. 3
0
        public void FullDownloadDeleteAndUpload_Default_FileExistsThenTemplateNotInTfsAndThenNewTemplateInTfs()
        {
            IProcessTemplates processTemplates       = ProcessTemplateFactory.CreateProcessTemplateMananger(TestConstants.TfsCollectionUri);
            int             currentDefaultTemplateID = processTemplates.ListProcessTemplates().OrderBy(o => o.Rank).FirstOrDefault().TemplateId;
            ProcessTemplate processTemplateToAction  = processTemplates.ListProcessTemplates().OrderByDescending(o => o.Rank).FirstOrDefault(); // not the default

            Assert.IsNotNull(processTemplateToAction);
            Assert.AreNotEqual(processTemplateToAction.TemplateId, currentDefaultTemplateID, "The selected template is the current default process template, please in sure there is 2 or more templates in the current Tfs Collection.");

            int templateCountToStartWith = processTemplates.ListProcessTemplates().Count;

            // download template
            string downloadedTemplateZipFile = processTemplates.DownloadTemplateAndReturnPathToZip(processTemplateToAction.Name);

            Assert.IsTrue(File.Exists(downloadedTemplateZipFile), "The template didn't download");

            // delete the process template
            processTemplates.DeleteTemplate(processTemplateToAction.Name);
            ProcessTemplate processTemplateAfterDelete = processTemplates.ListProcessTemplates().FirstOrDefault(o => string.Compare(o.Name, processTemplateToAction.Name, true) == 0);

            Assert.IsNull(processTemplateAfterDelete, "The process template didn't delete properly (processTemplateAfterDelete != null).");
            int templateCountAfterDelete = processTemplates.ListProcessTemplates().Count;

            Assert.IsTrue(templateCountToStartWith > templateCountAfterDelete, "The process template didn't delete properly (templateCountToStartWith > templateCountAfterDelete).");

            // upload process template
            processTemplates.UploadTemplate(processTemplateToAction.Name, processTemplateToAction.Description, downloadedTemplateZipFile);
            ProcessTemplate processTemplateAfterUpload = processTemplates.ListProcessTemplates().FirstOrDefault(o => string.Compare(o.Name, processTemplateToAction.Name, true) == 0);

            Assert.IsNotNull(processTemplateAfterUpload, "The process template didn't upload properly (processTemplateAfterUpload == null).");
            int templateCountAfterUpload = processTemplates.ListProcessTemplates().Count;

            Assert.IsTrue(templateCountAfterUpload > templateCountAfterDelete, "The process template didn't upload properly (templateCountAfterUpload > templateCountAfterDelete).");
            Assert.IsTrue(templateCountToStartWith == templateCountAfterUpload, "The process template didn't upload properly (templateCountToStartWith == templateCountAfterUpload).");

            // check first template id is not current template id
            Assert.IsTrue(processTemplateToAction.TemplateId != processTemplateAfterUpload.TemplateId, "Something didn't work properly.");

            // check default template id hasn't changed
            int currentDefaultTemplateAfterWorking = processTemplates.ListProcessTemplates().OrderBy(o => o.Rank).FirstOrDefault().TemplateId;

            Assert.IsTrue(currentDefaultTemplateID == currentDefaultTemplateAfterWorking, "The Default process template ID has changed.");

            // Make default template
            processTemplates.MakeDefaultTemplate(processTemplateAfterUpload.Name);
            int currentDefaultTemplateAfterMakingDefault = processTemplates.ListProcessTemplates().OrderBy(o => o.Rank).FirstOrDefault().TemplateId;

            Assert.IsTrue(processTemplateAfterUpload.TemplateId == currentDefaultTemplateAfterMakingDefault, "The Default process template wasn't set correctly.");
        }
Esempio n. 4
0
        public void CreateAndDeleteTeamProject_PassInTestProjectDetails_ProjectListToReturnTheNewProjectInTheListAndThenTheProjectToBeRemovedAndVerifyTheWarnings()
        {
            // arrange
            ITeamProjects teamProjects = TeamProjectFactory.CreateTeamProjectMananger(TestConstants.TfsCollectionUri);
            string        projectName  = TestProjectNameBase + Guid.NewGuid().ToString("N");

            IProcessTemplates processTemplates    = ProcessTemplateFactory.CreateProcessTemplateMananger(TestConstants.TfsCollectionUri);
            string            processTemplateName = processTemplates.ListProcessTemplates()[0].Name;

            // act
            teamProjects.CreateTeamProject(projectName, projectName + " Description", processTemplateName, false, false);

            // assert
            bool actual = false;

            foreach (string project in teamProjects.ListTeamProjectNames())
            {
                if (string.Compare(project, projectName, true) == 0)
                {
                    actual = true;
                    break;
                }
            }

            Assert.IsTrue(actual, "Create Failed.");
            List <Exception> exceptions;

            teamProjects.DeleteTeamProject(projectName, out exceptions, true, false);

            bool actualAfter = false;

            foreach (string project in teamProjects.ListTeamProjectNames())
            {
                if (string.Compare(project, projectName, true) == 0)
                {
                    actualAfter = true;
                    break;
                }
            }

            Assert.IsFalse(actualAfter, "Delete Failed.");
        }
Esempio n. 5
0
        public static void AssemblyInit(TestContext context)
        {
            using (ITeamProjectCollections teamProjectCollections = TeamProjectCollectionFactory.CreateTeamProjectCollectionMananger(TestConstants.TfsUri, TestConstants.DefaultCredentials))
            {
                if (!teamProjectCollections.CollectionExists(TestConstants.TfsCollectionName))
                {
                    teamProjectCollections.CreateProjectCollection(TestConstants.TfsCollectionName, TestConstants.TfsCollectionDescription);
                }
            }

            using (ITeamProjects teamProjectCollections = TeamProjectFactory.CreateTeamProjectMananger(TestConstants.TfsCollectionUri, TestConstants.DefaultCredentials))
            {
                if (!teamProjectCollections.TeamProjectExists(TestConstants.TfsTeamProjectName))
                {
                    string            processName      = string.Empty;
                    IProcessTemplates processTemplates = ProcessTemplateFactory.CreateProcessTemplateMananger(TestConstants.TfsCollectionUri);
                    processName = processTemplates.ListProcessTemplates()[0].Name;
                    if (!teamProjectCollections.CreateTeamProject(TestConstants.TfsTeamProjectName, TestConstants.TfsTeamProjectDescription, processName, false, false))
                    {
                        throw new Exception("Failed to create the default project for TFS API Tests.");
                    }
                }
            }
        }
Esempio n. 6
0
        public void InstanceFromFactory()
        {
            IProcessTemplates processTemplates = ProcessTemplateFactory.CreateProcessTemplateMananger(TestConstants.TfsCollectionUri);

            Assert.IsInstanceOfType(processTemplates, typeof(IProcessTemplates));
        }