Microsoft.Protocols.TestSuites.Common.Common.IsRequirementEnabled C# (CSharp) Method

IsRequirementEnabled() public static method

Check whether the specified requirement is enabled to run or not.
public static IsRequirementEnabled ( int requirementId, ITestSite site ) : bool
requirementId int The unique requirement number.
site ITestSite An instance of interface ITestSite which provides logging, assertions, /// and adapters for test code onto its execution context.
return bool
        public static bool IsRequirementEnabled(int requirementId, ITestSite site)
        {
            string requirementPropertyName = string.Format("R{0}Enabled", requirementId);
            string requirementPropertyValue = GetConfigurationPropertyValue(requirementPropertyName, site);

            if (string.Compare("true", requirementPropertyValue, true) != 0 && string.Compare("false", requirementPropertyValue, true) != 0)
            {
                site.Assume.Fail("The property {0} value must be true or false in the SHOULD/MAY ptfconfig file.", requirementPropertyName);
            }

            return string.Compare("true", requirementPropertyValue, true) == 0;
        }

Usage Example

Example #1
0
        /// <summary>
        ///  A method used to process unsupported Product behavior, it perform a directly capture for a requirement which describe an implementation does support  products.
        /// </summary>
        /// <param name="testDocumentShortName">The value of the test document short name.</param>
        /// <param name="requirementId">The value of the test requirement id of which requirement describe an implementation does support  products. </param>
        /// <param name="requirementDescription">The value of the test requirement description.</param>
        /// <param name="currentTestSite">An instance of the TestSite.</param>
        public static void ProcessingUnsupportProducts(string testDocumentShortName, int requirementId, string requirementDescription, ITestSite currentTestSite)
        {
            if (null == currentTestSite)
            {
                throw new ArgumentNullException("currentTestSite");
            }

            if (Common.IsRequirementEnabled(testDocumentShortName, requirementId, currentTestSite))
            {
                string documentShortName = string.Empty;

                // If the testDocumentShortName parameter do not have value, try to get from the DefaultProtocolDocShortName property of ITestSite instance.
                if (string.IsNullOrEmpty(testDocumentShortName))
                {
                    documentShortName = currentTestSite.DefaultProtocolDocShortName;
                }
                else
                {
                    documentShortName = testDocumentShortName;
                }

                if (string.IsNullOrEmpty(documentShortName))
                {
                    currentTestSite.CaptureRequirement(requirementId, requirementDescription);
                }
                else
                {
                    currentTestSite.CaptureRequirement(documentShortName, requirementId, requirementDescription);
                }
            }
            else
            {
                SutVersion currentSutVersion = Common.GetConfigurationPropertyValue <SutVersion>("SutVersion", currentTestSite);
                currentTestSite.Assert.Inconclusive("This test suite does not support current SUT version[{0}].", currentSutVersion);
            }
        }
Common