예제 #1
0
        /// <summary>Compares two PendingSet objects to determine if they're equal.</summary>
        /// <param name="obj1">The first PendingSet to compare.</param>
        /// <param name="obj2">The second PendingSet to compare.</param>
        public static bool IsEqual(PendingSet obj1, PendingSet obj2)
        {
            bool retValue = false;

            if ((obj1 != null) && (obj2 != null))
            {
                if (obj1.TestSetId == obj2.TestSetId)
                {
                    retValue = true;
                }
            }

            return(retValue);
        }
예제 #2
0
        /// <summary>Gets automated test runs for the specified TexstSetLaunch class.</summary>
        /// <param name="testSetLaunch">The specified data from a TST file.</param>
        /// <returns>PendingSet</returns>
        public PendingSet GetSpecifiedTests(TestSetLaunch testSetLaunch)
        {
            PendingSet retSet = null;

            //The testset.
            RemoteTestSet testSet = null;

            //Get the test set, first.
            if (testSetLaunch.ProjectId == null)
            {
                //Have to find the projectId.
                RemoteProject[] remoteProjects = this._client.Project_Retrieve();
                for (int i = 0; i < remoteProjects.Length && testSet == null; i++)
                {
                    //Connect to the project.
                    if (this._client.Connection_ConnectToProject(remoteProjects[i].ProjectId.Value))
                    {
                        testSet = this._client.TestSet_RetrieveById(testSetLaunch.TestSetId);
                    }
                }
            }
            else
            {
                if (this._client.Connection_ConnectToProject(testSetLaunch.ProjectId.Value))
                {
                    testSet = this._client.TestSet_RetrieveById(testSetLaunch.TestSetId);
                }
            }

            //Now get the newly created test runs..
            if (testSet != null)
            {
                //Get the tests for the testset.
                List <RemoteAutomatedTestRun> testRuns = new List <RemoteAutomatedTestRun>();
                testRuns.AddRange(this._client.TestRun_CreateForAutomatedTestSet(testSetLaunch.TestSetId, this.HostName));

                //Create and add the pending set.
                retSet = new PendingSet(testSet.Name);
                foreach (RemoteAutomatedTestRun testRun in testRuns)
                {
                    testRun.ScheduledDate = DateTime.Now;
                    retSet.AddPendingTestRun(testRun);
                }
            }

            return(retSet);
        }
예제 #3
0
        /// <summary>Whether or not the given object is the same as this one. Checks TestSetId only.</summary>
        /// <param name="obj">Object to compare.</param>
        /// <returns>True if objects are the same, false if not.</returns>
        public override bool Equals(object obj)
        {
            bool retValue = false;

            if (obj != null)
            {
                if (obj.GetType() == typeof(PendingSet))
                {
                    PendingSet objCompare = (PendingSet)obj;
                    if (objCompare.TestSetId == this.TestSetId)
                    {
                        retValue = true;
                    }
                }
            }
            return(retValue);
        }
예제 #4
0
        /// <summary>Retrieves the upcoming tests that are scheduled up to the toDate.</summary>
        /// <param name="toDate">The date for the cutoff of upcoming tests.</param>
        /// <returns>A list of upcoming test runs.</returns>
        public List <PendingSet> GetUpcomingTests(DateTime toDate)
        {
            DateRange dteRange = new DateRange()
            {
                StartDate = DateTime.Now, EndDate = toDate
            };

            //Create a new dictionary..
            Dictionary <int, PendingSet> setRuns = new Dictionary <int, PendingSet>();

            //Get a list of projects and loop through each one.
            RemoteProject[] remoteProjects = this._client.Project_Retrieve();
            foreach (RemoteProject remoteProject in remoteProjects)
            {
                try
                {
                    if (this._client.Connection_ConnectToProject(remoteProject.ProjectId.Value))
                    {
                        RemoteAutomatedTestRun[] testRuns = this._client.TestRun_CreateForAutomationHost(this.HostName, dteRange);
                        //Loop through each TestRun..
                        foreach (RemoteAutomatedTestRun testRun in testRuns)
                        {
                            //If the test set already exists..
                            if (setRuns.ContainsKey(testRun.TestSetId.Value))
                            {
                                //Add it.
                                setRuns[testRun.TestSetId.Value].AddPendingTestRun(testRun);
                            }
                            else
                            {
                                //Create a new one and add it.
                                //Get the test set name..
                                string strTestSetName = "Test Set #" + testRun.TestSetId.Value.ToString();
                                try
                                {
                                    RemoteTestSet specifiedTestSet = this._client.TestSet_RetrieveById(testRun.TestSetId.Value);
                                    strTestSetName = specifiedTestSet.Name;
                                }
                                catch { }

                                //Create and add the pending set.
                                PendingSet newSet = new PendingSet(strTestSetName, testRun);
                                newSet.OverDue = (testRun.ScheduledDate < DateTime.Now);
                                setRuns.Add(testRun.TestSetId.Value, newSet);
                            }
                        }
                    }
                    else
                    {
                        Logger.LogMessage("Error retrieving upcoming tests. Could not connect to project #" + remoteProject.ProjectId, System.Diagnostics.EventLogEntryType.Warning);
                    }
                }
                catch
                {
                    //No reason to log an error here.
                }
            }

            //Copy over the pending sets into a new date-ordered list.
            List <PendingSet> retDict = new List <PendingSet>();

            foreach (KeyValuePair <int, PendingSet> pendingSet in setRuns)
            {
                retDict.Add(pendingSet.Value);
            }

            return(retDict);
        }
예제 #5
0
 public RunTestThread(SpiraConnect client, PendingSet testToRun)
 {
     this._testsToRun = testToRun;
     this._client     = client;
 }
예제 #6
0
 public WorkCompletedArgs(PendingSet TestSet, Exception ex, WorkCompletedStatusEnum FinishStatus)
 {
     this._testSet   = TestSet;
     this._exception = ex;
     this.Status     = FinishStatus;
 }