Example #1
0
        /// <summary>
        ///  Get Custom property values from test cases.
        /// </summary>
        /// <param name="testCase">TestCase object extracted from the TestResult</param>
        /// <returns> list of properties</returns>
        public static List <string> GetTicketNumber(ObjectModel.TestCase testCase)
        {
            var           properties   = testCase.GetProperties();
            List <string> ticketNumber = new List <string>();

            foreach (var propertyGroup in properties)
            {
                if (testCase.GetPropertyValue(propertyGroup.Key) is KeyValuePair <String, String>[])
                {
                    KeyValuePair <String, String>[] kvparr = ((IEnumerable)testCase.GetPropertyValue(propertyGroup.Key)).Cast <object>()
                                                             .Select(x => (KeyValuePair <String, String>)x)
                                                             .ToArray();
                    foreach (KeyValuePair <String, String> property in kvparr)
                    {
                        if (property.Key == "TicketNumber")
                        {
                            ticketNumber.Add(property.Value);
                        }
                    }
                }
            }
            if (ticketNumber.Count == 0)
            {
                return(null);
            }
            return(ticketNumber);
        }
Example #2
0
        /// <summary>
        /// Return TMI Test id when available for TestPlatform TestCase.
        /// </summary>
        /// <param name="rockSteadyTestCase">
        /// The rock Steady Test Case.
        /// </param>
        /// <returns>
        /// The <see cref="Guid"/>.
        /// </returns>
        private static Guid GetTmiTestId(ObjectModel.TestCase rockSteadyTestCase)
        {
            Guid tmiTestId = Guid.Empty;

            ObjectModel.TestProperty tmiTestIdProperty = rockSteadyTestCase.Properties.FirstOrDefault(property => property.Id.Equals(TmiTestIdPropertyIdentifier));
            if (null != tmiTestIdProperty)
            {
                tmiTestId = rockSteadyTestCase.GetPropertyValue(tmiTestIdProperty, Guid.Empty);
            }
            return(tmiTestId);
        }
Example #3
0
        /// <summary>
        ///  Get Custom property values from test cases.
        /// </summary>
        /// <param name="testCase">TestCase object extracted from the TestResult</param>
        /// <param name="categoryID">Property Name from the list of properties in TestCase</param>
        /// <returns> list of properties</returns>
        public static List <string> GetCustomPropertyValueFromTestCase(ObjectModel.TestCase testCase, string categoryID)
        {
            var customProperty = testCase.Properties.FirstOrDefault(t => t.Id.Equals(categoryID));

            if (customProperty != null)
            {
                var cateogryValues = (string[])testCase.GetPropertyValue(customProperty);
                if (cateogryValues != null)
                {
                    return(cateogryValues.ToList());
                }
                else
                {
                    return(Enumerable.Empty <String>().ToList());
                }
            }

            return(Enumerable.Empty <String>().ToList());
        }
Example #4
0
        /// <summary>
        /// Gets test id.
        /// Return TMI Test id when available for TestPlatform test case.
        /// </summary>
        /// <param name="rockSteadyTestCase"></param>
        /// <returns>Test id</returns>
        public static Guid GetTestId(ObjectModel.TestCase rockSteadyTestCase)
        {
            Guid testId = Guid.Empty;

            // Setting test id to tmi test id.
            ObjectModel.TestProperty tmiTestIdProperty = rockSteadyTestCase.Properties.FirstOrDefault(
                property => property.Id.Equals(Constants.TmiTestIdPropertyIdentifier));

            if (null != tmiTestIdProperty)
            {
                testId = rockSteadyTestCase.GetPropertyValue(tmiTestIdProperty, Guid.Empty);
            }

            // If tmi test id not present, picking from platform test id.
            if (Guid.Empty.Equals(testId))
            {
                testId = rockSteadyTestCase.Id;
            }

            return(testId);
        }
Example #5
0
 private static string ClassNameForTest(TPOM.TestCase testCase) =>
 testCase.GetPropertyValue(Constants.TestClassNameProperty) as string;
        /// <summary>
        /// Gets tcm properties from test case.
        /// </summary>
        /// <param name="testCase">Test case.</param>
        /// <returns>Tcm properties.</returns>
        public static IDictionary <TestPlatformObjectModel.TestProperty, object> GetTcmProperties(TestPlatformObjectModel.TestCase testCase)
        {
            var tcmProperties = new Dictionary <TestPlatformObjectModel.TestProperty, object>();

            // Return empty properties when testCase is null or when test case id is zero.
            if (testCase == null ||
                testCase.GetPropertyValue <int>(Constants.TestCaseIdProperty, default(int)) == 0)
            {
                return(tcmProperties);
            }

            // Step 1: Add common properties.
            tcmProperties[Constants.TestRunIdProperty]              = testCase.GetPropertyValue <int>(Constants.TestRunIdProperty, default(int));
            tcmProperties[Constants.TestPlanIdProperty]             = testCase.GetPropertyValue <int>(Constants.TestPlanIdProperty, default(int));
            tcmProperties[Constants.BuildConfigurationIdProperty]   = testCase.GetPropertyValue <int>(Constants.BuildConfigurationIdProperty, default(int));
            tcmProperties[Constants.BuildDirectoryProperty]         = testCase.GetPropertyValue <string>(Constants.BuildDirectoryProperty, default(string));
            tcmProperties[Constants.BuildFlavorProperty]            = testCase.GetPropertyValue <string>(Constants.BuildFlavorProperty, default(string));
            tcmProperties[Constants.BuildNumberProperty]            = testCase.GetPropertyValue <string>(Constants.BuildNumberProperty, default(string));
            tcmProperties[Constants.BuildPlatformProperty]          = testCase.GetPropertyValue <string>(Constants.BuildPlatformProperty, default(string));
            tcmProperties[Constants.BuildUriProperty]               = testCase.GetPropertyValue <string>(Constants.BuildUriProperty, default(string));
            tcmProperties[Constants.TfsServerCollectionUrlProperty] = testCase.GetPropertyValue <string>(Constants.TfsServerCollectionUrlProperty, default(string));
            tcmProperties[Constants.TfsTeamProjectProperty]         = testCase.GetPropertyValue <string>(Constants.TfsTeamProjectProperty, default(string));
            tcmProperties[Constants.IsInLabEnvironmentProperty]     = testCase.GetPropertyValue <bool>(Constants.IsInLabEnvironmentProperty, default(bool));

            // Step 2: Add test case specific properties.
            tcmProperties[Constants.TestCaseIdProperty]            = testCase.GetPropertyValue <int>(Constants.TestCaseIdProperty, default(int));
            tcmProperties[Constants.TestConfigurationIdProperty]   = testCase.GetPropertyValue <int>(Constants.TestConfigurationIdProperty, default(int));
            tcmProperties[Constants.TestConfigurationNameProperty] = testCase.GetPropertyValue <string>(Constants.TestConfigurationNameProperty, default(string));
            tcmProperties[Constants.TestPointIdProperty]           = testCase.GetPropertyValue <int>(Constants.TestPointIdProperty, default(int));

            return(tcmProperties);
        }