Microsoft.Protocols.TestSuites.MS_ADMINS.TestSuiteBase.GenerateRandomNumber C# (CSharp) Method

GenerateRandomNumber() public static method

This method is used to random generate an integer in the specified range.
public static GenerateRandomNumber ( int minValue, int maxValue ) : int
minValue int The inclusive lower bound of the random number returned.
maxValue int The exclusive upper bound of the random number returned.
return int
        public static int GenerateRandomNumber(int minValue, int maxValue)
        {
            random = new Random((int)DateTime.Now.Ticks);
            return random.Next(minValue, maxValue);
        }

Usage Example

Example #1
0
        public void MSADMINS_S02_TC09_CreateSiteFailed_LcidInvalid()
        {
            string strErrorCode = string.Empty;
            int    invalidLcid  = TestSuiteBase.GenerateRandomNumber(0, 99);
            string title        = TestSuiteBase.GenerateUniqueSiteTitle();
            string url          = TestSuiteBase.GenerateUrlPrefixWithPortNumber() + title;
            string description  = TestSuiteBase.GenerateRandomString(20);
            string webTemplate  = Common.GetConfigurationPropertyValue("CustomizedTemplate", this.Site);
            string ownerLogin   = Common.GetConfigurationPropertyValue("OwnerLogin", this.Site);
            string ownerName    = TestSuiteBase.GenerateUniqueOwnerName();
            string ownerEmail   = TestSuiteBase.GenerateEmail(20);
            string portalUrl    = TestSuiteBase.GeneratePortalUrl(20);
            string portalName   = TestSuiteBase.GenerateUniquePortalName();

            try
            {
                // Call CreateSite to create a site collection with an invalid LCID.
                this.adminsAdapter.CreateSite(url, title, description, invalidLcid, webTemplate, ownerLogin, ownerName, ownerEmail, portalUrl, portalName);
            }
            catch (SoapException exp)
            {
                strErrorCode = Common.ExtractErrorCodeFromSoapFault(exp);
                Site.Log.Add(LogEntryKind.Debug, "Soap exception returned, it means the create site operation failed with invalid LCID inputting, the message is: {0}", exp.Message);
            }

            // If the returned error code equals to 0x8102005e, then MS-ADMINS_R18 can be captured.
            Site.CaptureRequirementIfAreEqual <string>(
                "0x8102005e",
                strErrorCode,
                18,
                @"[In CreateSiteSoapIn] If the LCID is invalid [or not installed], then the server MUST return a SOAP fault with error code 0x8102005e.");
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_ADMINS.TestSuiteBase::GenerateRandomNumber