Example #1
0
        public void GetTLProject_Id_ThreeProjects()
        {
            var ids = new [] { "prj1", "prj2", "prj3" };

            var list = new List <TestProject>();

            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project1",
                    "prj1",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project2",
                    "prj2",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project3",
                    "prj3",
                    string.Empty));

            var resultList = getProjectCollection(list, null, ids, false);

            Assert.AreEqual(
                list,
                UnitTestOutput.LastOutput.AsList <TestProject>());
        }
Example #2
0
        List <TestProject> getProjectCollection(
            List <TestProject> listOfProjects,
            string[] names,
            string[] ids,
            bool makeFail)
        {
            var cmdlet = new GetTLProjectCommand();

            cmdlet.Name = names;
            cmdlet.Id   = ids;

            TLAddinData.CurrentTestLinkConnection =
                FakeTestLinkFactory.GetTestLinkWithProjects(listOfProjects);

            if (makeFail)
            {
                TLAddinData.CurrentTestLinkConnection = null;
            }

            var command = new TLSrvGetProjectCommand(cmdlet);

            command.Execute();

            var resultList = new List <TestProject>();

            foreach (object tpr in UnitTestOutput.LastOutput)
            {
                resultList.Add((TestProject)tpr);
            }

            return(resultList);
        }
        private System.Collections.Generic.List <TestProject> getProject(
            System.Collections.Generic.List <TestProject> listOfProjects,
            string[] names,
            bool makeFail)
        {
            TLProjectCmdletBase cmdlet = new TLProjectCmdletBase();

            cmdlet.Name = names;

            TLAddinData.CurrentTestLinkConnection =
                FakeTestLinkFactory.GetTestLinkWithProjects(listOfProjects);

            if (makeFail)
            {
                TLAddinData.CurrentTestLinkConnection = null;
            }
//cmdlet.WriteTrace(cmdlet, "getProject 00001");
            TLSrvGetProjectCommand command =
                new TLSrvGetProjectCommand(cmdlet);

            command.Execute();
//cmdlet.WriteTrace(cmdlet, "getProject 00002");
            System.Collections.Generic.List <TestProject> resultList =
                new System.Collections.Generic.List <TestProject>();
//cmdlet.WriteTrace(cmdlet, "getProject 00003");
            foreach (object tpr in PSTestLib.UnitTestOutput.LastOutput)
            {
//cmdlet.WriteTrace(cmdlet, "getProject 00004_1");
                resultList.Add((TestProject)tpr);
//cmdlet.WriteTrace(cmdlet, "getProject 00004_2");
            }

            return(resultList);
        }
        public void GetTLProject_with_params_one_project_by_name()
        {
            string projectName = "project01";

            System.Collections.Generic.List <TestProject> list =
                new System.Collections.Generic.List <TestProject>();
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project00",
                    "prj0",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    projectName,
                    "prj1",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project02",
                    "prj2",
                    string.Empty));

            System.Collections.Generic.List <TestProject> resultList =
                getProject(list, (new string[] { projectName }), false);

            list.RemoveAt(2);
            list.RemoveAt(0);

            Assert.AreEqual <System.Collections.Generic.List <TestProject> >(
                list,
                resultList);
        }
        public void GetTLProject_broken_connection()
        {
            System.Collections.Generic.List <TestProject> list =
                new System.Collections.Generic.List <TestProject>();
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project1",
                    "prj1",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project2",
                    "prj2",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project3",
                    "prj3",
                    string.Empty));
//cmdlet.WriteTrace(cmdlet, "GetTLProject_broken_connection: 001");
            System.Collections.Generic.List <TestProject> resultList =
                getProjectCollection(list, true);
//cmdlet.WriteTrace(cmdlet, "GetTLProject_broken_connection: 002");
            Assert.AreEqual <System.Collections.Generic.List <TestProject> >(
                (new System.Collections.Generic.List <TestProject>()),
                resultList);
        }
Example #6
0
        public void TestProject_from_pipeline_with_broken_connection()
        {
            System.Collections.Generic.List <TestProject> listOfProjects =
                new System.Collections.Generic.List <TestProject>();
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project",
                    "prj",
                    string.Empty));

            System.Collections.Generic.List <TestPlan> listOfTestPlans =
                new System.Collections.Generic.List <TestPlan>();
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));

            System.Collections.Generic.List <TestPlan> resultList =
                getTestPlansFromProjectsInPipeline(listOfProjects, listOfTestPlans, true, false);

            Assert.AreEqual <System.Collections.Generic.List <TestPlan> >(
                (new System.Collections.Generic.List <TestPlan>()),
                resultList);
        }
        public void GetTLProject_three_projects()
        {
            System.Collections.Generic.List <TestProject> list =
                new System.Collections.Generic.List <TestProject>();
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project1",
                    "prj1",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project2",
                    "prj2",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project3",
                    "prj3",
                    string.Empty));

            System.Collections.Generic.List <TestProject> resultList =
                getProjectCollection(list, false);

            Assert.AreEqual <System.Collections.Generic.List <TestProject> >(
                list,
                resultList);
        }
Example #8
0
        // no project specified and there's no project in the store


        private System.Collections.Generic.List <TestPlan> getTestPlansByProjectName(
            TestProject currentTestProject,
            string[] testProjectNames,
            System.Collections.Generic.List <TestPlan> testPlans,
            bool makeFail,
            bool projectNamesNotSpecified)
        {
            TLGetTestPlanCmdletBase cmdlet = new TLGetTestPlanCmdletBase();

            if (projectNamesNotSpecified)
            {
                cmdlet.TestProjectName = null;
            }
            else
            {
                cmdlet.TestProjectName = testProjectNames;
            }
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0001");
            System.Collections.Generic.List <TestProject> testProjects =
                new System.Collections.Generic.List <TestProject>();
            testProjects.Add(TLAddinData.CurrentTestProject);
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0002");

            TLAddinData.CurrentTestLinkConnection =
                FakeTestLinkFactory.GetTestLinkWithTestPlans(testProjects, testPlans, null, null);
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0003");
            if (projectNamesNotSpecified)
            {
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0004_1");
                TLAddinData.CurrentTestProject = currentTestProject;
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0004_2");
            }

            if (makeFail)
            {
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0005_1");
                TLAddinData.CurrentTestLinkConnection = null;
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0005_2");
            }

            TLSrvGetTestPlanCommand command =
                new TLSrvGetTestPlanCommand(cmdlet);

            command.Execute();
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0006");
            System.Collections.Generic.List <TestPlan> resultList =
                new System.Collections.Generic.List <TestPlan>();
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0007");
            foreach (object tpl in PSTestLib.UnitTestOutput.LastOutput)
            {
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0008_1");
                resultList.Add((TestPlan)tpl);
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0008_2");
            }
//cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0009");
            return(resultList);
        }
Example #9
0
        public void TestProject_not_specified()
        {
            System.Collections.Generic.List <TestProject> listOfProjects =
                new System.Collections.Generic.List <TestProject>();
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project01",
                    "prj",
                    string.Empty));
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project02",
                    "prj",
                    string.Empty));

            System.Collections.Generic.List <TestPlan> listOfTestPlans =
                new System.Collections.Generic.List <TestPlan>();
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan 01",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan 02",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[1].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan 03",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));

            System.Collections.Generic.List <TestPlan> resultList =
                getTestPlansFromProjectsInPipeline(listOfProjects, listOfTestPlans, false, true);

            listOfTestPlans.RemoveAt(1);

            Assert.AreEqual <System.Collections.Generic.List <TestPlan> >(
                //Assert.AreEqual<Meyn.TestLink.TestPlan>(
                listOfTestPlans,
                resultList);
        }
        private System.Collections.Generic.List <TestPlan> getTestPlansFromProjectsInPipelineByName(
            System.Collections.Generic.List <TestProject> testProjects,
            System.Collections.Generic.List <TestPlan> testPlans,
            string[] testPlanNames,
            bool makeFail,
            bool inputNotSpecified)
        {
            GetTLTestPlanCommand cmdlet = new GetTLTestPlanCommand();

            if (inputNotSpecified)
            {
                cmdlet.InputObject = null;
            }
            else
            {
                TestProject[] projectsArray =
                    testProjects.ToArray();
                cmdlet.InputObject = projectsArray;
            }
            cmdlet.TestPlanName = testPlanNames;

            TLAddinData.CurrentTestLinkConnection =
                FakeTestLinkFactory.GetTestLinkWithTestPlans(testProjects, testPlans, null, null);

            if (inputNotSpecified)
            {
                TLAddinData.CurrentTestProject = testProjects[0];
            }

            if (makeFail)
            {
                TLAddinData.CurrentTestLinkConnection = null;
            }

            TLSrvGetTestPlanCommand command =
                new TLSrvGetTestPlanCommand(cmdlet);

            command.Execute();

            System.Collections.Generic.List <TestPlan> resultList =
                new System.Collections.Generic.List <TestPlan>();

            foreach (object tpl in PSTestLib.UnitTestOutput.LastOutput)
            {
                resultList.Add((TestPlan)tpl);
            }

            return(resultList);
        }
Example #11
0
        public void GetTLProject_NoParameters_OneProject()
        {
            var list = new List <TestProject>();

            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project1",
                    "prj1",
                    string.Empty));

            var resultList = getProjectCollection(list, null, null, false);

            Assert.AreEqual(
                list,
                UnitTestOutput.LastOutput.AsList <TestProject>());
        }
        public void GetTLProject_with_params_three_projects_by_id()
        {
            string[] projectNames = { "project01", "project02", "project03" };

            System.Collections.Generic.List <TestProject> list =
                new System.Collections.Generic.List <TestProject>();
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    projectNames[0],
                    "prj1",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project04",
                    "prj4",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    projectNames[1],
                    "prj2",
                    string.Empty));
            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    projectNames[2],
                    "prj3",
                    string.Empty));

            int[] projectIds =
            { list[0].id, list[2].id, list[3].id };

            System.Collections.Generic.List <TestProject> resultList =
                getProject(list, projectNames, false);

            list.RemoveAt(1);

            Assert.AreEqual <int>(
                projectIds[0],
                resultList[0].id);

            Assert.AreEqual <int>(
                projectIds[1],
                resultList[1].id);

            Assert.AreEqual <int>(
                projectIds[2],
                resultList[2].id);
        }
        public void TestProject_from_pipeline_single_name()
        {
            System.Collections.Generic.List <TestProject> listOfProjects =
                new System.Collections.Generic.List <TestProject>();
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project",
                    "prj",
                    string.Empty));

            System.Collections.Generic.List <TestPlan> listOfTestPlans =
                new System.Collections.Generic.List <TestPlan>();
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan 01",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan 02",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan 03",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));

            System.Collections.Generic.List <TestPlan> resultList =
                getTestPlansFromProjectsInPipelineByName(listOfProjects, listOfTestPlans, (new string[] { "testplan 02" }), false, false);

            listOfTestPlans.RemoveAt(2);
            listOfTestPlans.RemoveAt(0);

            Assert.AreElementsSameIgnoringOrder <TestPlan>(
                listOfTestPlans,
                resultList);
        }
        public void GetTLProject_with_params_broken_connection()
        {
            string projectName = "project";

            System.Collections.Generic.List <TestProject> list =
                new System.Collections.Generic.List <TestProject>();

            list.Add(
                FakeTestLinkFactory.GetTestProject(
                    projectName,
                    "prj",
                    string.Empty));

            System.Collections.Generic.List <TestProject> resultList =
                getProject(list, (new string[] { projectName }), true);

            Assert.AreEqual <System.Collections.Generic.List <TestProject> >(
                (new System.Collections.Generic.List <TestProject>()),
                resultList);
        }
Example #15
0
        public void TestProject_by_name()
        {
            System.Collections.Generic.List <TestProject> listOfProjects =
                new System.Collections.Generic.List <TestProject>();
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project",
                    "prj",
                    string.Empty));

            System.Collections.Generic.List <TestPlan> listOfTestPlans =
                new System.Collections.Generic.List <TestPlan>();
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));
//cmdlet.WriteTrace(cmdlet, "TestProject_by_name: 0001");
            System.Collections.Generic.List <TestPlan> resultList =
                getTestPlansByProjectName(
                    listOfProjects[0],
                    (new string[1] {
                listOfProjects[0].name
            }),
                    listOfTestPlans,
                    false,
                    false);
//cmdlet.WriteTrace(cmdlet, "TestProject_by_name: 0002");
            Assert.AreEqual <System.Collections.Generic.List <TestPlan> >(
                //Assert.AreEqual<Meyn.TestLink.TestPlan>(
                (new System.Collections.Generic.List <TestPlan>()),
                resultList);
//cmdlet.WriteTrace(cmdlet, "TestProject_by_name: 0003");
        }
Example #16
0
        public void TestProjects_from_pipeline()
        {
            System.Collections.Generic.List <TestProject> listOfProjects =
                new System.Collections.Generic.List <TestProject>();
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project1",
                    "prj1",
                    string.Empty));
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project2",
                    "prj2",
                    string.Empty));
            listOfProjects.Add(
                FakeTestLinkFactory.GetTestProject(
                    "project3",
                    "prj3",
                    string.Empty));

            System.Collections.Generic.List <TestPlan> listOfTestPlans =
                new System.Collections.Generic.List <TestPlan>();
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan1",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[0].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan4",
                    "notes",
                    true,  // active
                    true,  // is_public
                    true,  // open
                    111)); //listOfProjects[2].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan2",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[1].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan3",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    listOfProjects[2].id));
            listOfTestPlans.Add(
                FakeTestLinkFactory.GetTestPlan(
                    "testplan5",
                    "notes",
                    true, // active
                    true, // is_public
                    true, // open
                    927));

            System.Collections.Generic.List <TestPlan> resultList =
                getTestPlansFromProjectsInPipeline(listOfProjects, listOfTestPlans, false, false);

            listOfTestPlans.RemoveAt(4);
            listOfTestPlans.RemoveAt(1);

            Assert.AreEqual <System.Collections.Generic.List <TestPlan> >(
                //Assert.AreEqual<Meyn.TestLink.TestPlan>(
                listOfTestPlans,
                resultList);
        }