/// <summary>
        /// Returns the selected test case numbers as collection
        /// </summary>
        /// <returns>Selected test cases</returns>
        private Collection <PrintTestData> GetSelectedTests()
        {
            int defaultduration = 0;
            Collection <PrintTestData> selectedTests = new Collection <PrintTestData>();
            PrintTestData data = null;

            // walk thru the data set and return the selected test cases
            foreach (CTCTestCaseDetailsDataSet.TestCaseDetailsRow row in cTCTestCaseDetails.TestCaseDetails.Rows)
            {
                var res = from durRes in _TestWithDuration where durRes.TestId.Equals((int)row.ID) select new { Duration = durRes.Duration };
                foreach (var item in res)
                {
                    defaultduration = item.Duration;
                }
                if (row.IsSelected || (defaultduration != row.Duration && (defaultduration > 0 || row.Duration > 0)))//row.IsSelected &&
                {
                    data               = new PrintTestData();
                    data.TestId        = (int)row.ID;
                    data.Duration      = (int)row.Duration;
                    data.PrintProtocol = (PrintProtocolType)Enum.Parse(typeof(PrintProtocolType), row.PrintProtocol);
                    selectedTests.Add(data);
                }
                defaultduration = 0;
            }

            return(selectedTests);
        }
        /// <summary>
        /// Loads the test case from the current assembly using the reflection
        /// Read the attributes like id, category, description.
        /// </summary>
        public bool LoadTestCases(Type type, Collection <int> selectedTests = null, PluginType plugin = PluginType.Default, Collection <PrintTestData> testDurationDetails = null)
        {
            if (!plugin.Equals(PluginType.Default))
            {
                _pluginType = plugin;
            }

            _type = type;
            PrintTestData Testdata = null;

            selectAll_CheckBox.Checked = false;

            if (plugin == PluginType.Print)
            {
                // Hide and show the columns based on the plug-in type
                durationDataGridViewTextBoxColumn.Visible      = true;
                connectivityDataGridViewTextBoxColumn.Visible  = false;
                printProtocolDataGridViewTextBoxColumn.Visible = false;
                portNumberDataGridViewTextBoxColumn.Visible    = false;

                testCaseDetails_DataGrid.ScrollBars = ScrollBars.Vertical;
            }

            if (plugin == PluginType.IPConfiguration)
            {
                connectivityDataGridViewTextBoxColumn.Visible = false;
            }

            if (null == type || null == productCategory_ComboBox.SelectedItem)
            {
                return(false);
            }

            ProductFamilies selectedCategory = (ProductFamilies)Enum.Parse(typeof(ProductFamilies), productCategory_ComboBox.SelectedItem.ToString());

            // clear the previous rows before adding any new rows
            cTCTestCaseDetails.TestCaseDetails.Clear();

            // walk thru all the methods inside the class and check if the method has TestDetails
            // then add to the data set.
            foreach (MethodInfo methodInfo in type.GetMethods())
            {
                object[] attrs = methodInfo.GetCustomAttributes(new TestDetailsAttribute().GetType(), false);

                if (attrs.Length > 0)
                {
                    // since we are having only the TestDetails type custom attributes so we can cast to this type
                    TestDetailsAttribute details = (TestDetailsAttribute)attrs[0];

                    if (details.ProductCategory.HasFlag(selectedCategory))
                    {
                        // create the row data
                        CTCTestCaseDetailsDataSet.TestCaseDetailsRow row = cTCTestCaseDetails.TestCaseDetails.NewTestCaseDetailsRow();

                        row.IsSelected = selectedTests != null && selectedTests.Contains(details.Id);

                        if (plugin.Equals(PluginType.Print) || _pluginType.Equals(PluginType.Print))
                        {
                            bool durationAssigned = false;
                            uint duration         = 0;
                            if (testDurationDetails != null && testDurationDetails.Count > 0)
                            {
                                var res = from data in testDurationDetails where data.TestId.Equals(details.Id) select new { Duration = data.Duration };
                                foreach (var item in res)
                                {
                                    duration         = Convert.ToUInt32(item.Duration);
                                    row.Duration     = duration;
                                    durationAssigned = true;
                                    break;
                                }
                            }
                            if (!durationAssigned)
                            {
                                row.Duration = details.PrintDuration;
                            }

                            if (details.PrintDuration > 0)//row.IsSelected &&
                            {
                                Testdata          = new PrintTestData();
                                Testdata.TestId   = (int)details.Id;
                                Testdata.Duration = (int)details.PrintDuration;
                                _TestWithDuration.Add(Testdata);
                            }
                            row.PrintProtocol = details.PrintProtocol.ToString();
                            row.PortNumber    = details.PortNumber;
                        }

                        row.Category     = details.Category;
                        row.ID           = (uint)details.Id;
                        row.Description  = details.Description;
                        row.Protocol     = details.Protocol.ToString();
                        row.Connectivity = details.Connectivity.ToString();


                        cTCTestCaseDetails.TestCaseDetails.AddTestCaseDetailsRow(row);
                    }
                }
            }
            return(true);
        }