GetIntPtfProperty() public static method

Get a string type PTF property.
public static GetIntPtfProperty ( ITestSite testSite, string propName, int &propIntValue ) : bool
testSite ITestSite The test site where to get from.
propName string The property name.
propIntValue int
return bool
        protected void LoadConfig()
        {
            #region Read and convert properties from PTFCONFIG file

            #region Security Approach and Protocol
            string strRDPSecurityProtocol;
            bool   isNegotiationBased = true;
            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased))
            {
                assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation);
            }

            selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG;
            if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol))
            {
                assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol);
            }

            // Check the combination of RdpSecurityNegotiation and RdpSecurityProtocol
            if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase))
            {
                selectedProtocol = selectedProtocols_Values.PROTOCOL_SSL_FLAG;
                this.TestSite.Assume.IsTrue(
                    isNegotiationBased,
                    "When TLS is used as the security protocol, {0} is set to 'TLS', {1} must be true.",
                    RdpPtfPropNames.RdpSecurityProtocol,
                    RdpPtfPropNames.RdpSecurityNegotiation);
                transportProtocol = EncryptedProtocol.NegotiationTls;
            }
            else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase))
            {
                selectedProtocol = selectedProtocols_Values.PROTOCOL_HYBRID_FLAG;
                if (isNegotiationBased)
                {
                    transportProtocol = EncryptedProtocol.NegotiationCredSsp;
                }
                else
                {
                    transportProtocol = EncryptedProtocol.DirectCredSsp;
                }
            }
            else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase))
            {
                selectedProtocol  = selectedProtocols_Values.PROTOCOL_RDP_FLAG;
                transportProtocol = EncryptedProtocol.Rdp;
            }
            else
            {
                assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol);
            }
            #endregion

            #region Encryption Level
            string strRDPSecurityEncryptionLevel;
            enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW;
            if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionLevel, out strRDPSecurityEncryptionLevel))
            {
                assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel);
            }
            else
            {//None, Low, Client, High, FIPS
                if (strRDPSecurityEncryptionLevel.Equals("None", StringComparison.CurrentCultureIgnoreCase))
                {
                    enLevel = EncryptionLevel.ENCRYPTION_LEVEL_NONE;
                }
                else if (strRDPSecurityEncryptionLevel.Equals("Low", StringComparison.CurrentCultureIgnoreCase))
                {
                    enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW;
                }
                else if (strRDPSecurityEncryptionLevel.Equals("Client", StringComparison.CurrentCultureIgnoreCase))
                {
                    enLevel = EncryptionLevel.ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
                }
                else if (strRDPSecurityEncryptionLevel.Equals("High", StringComparison.CurrentCultureIgnoreCase))
                {
                    enLevel = EncryptionLevel.ENCRYPTION_LEVEL_HIGH;
                }
                else if (strRDPSecurityEncryptionLevel.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase))
                {
                    enLevel = EncryptionLevel.ENCRYPTION_LEVEL_FIPS;
                }
                else
                {
                    assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel);
                }
            }

            if (transportProtocol == EncryptedProtocol.Rdp && enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE)
            {
                this.TestSite.Assert.Fail("When use Standard RDP Security, the encryption level must be greater than None.");
            }

            if (transportProtocol != EncryptedProtocol.Rdp && enLevel != EncryptionLevel.ENCRYPTION_LEVEL_NONE)
            {
                this.TestSite.Assert.Fail("When use enhanced security protocls (TLS or CredSSP), the encryption level MUST be None.");
            }

            #endregion

            #region Encryption Method
            string strRDPSecurityEncryptionMethod;
            enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT;
            if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionMethod, out strRDPSecurityEncryptionMethod))
            {
                assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod);
            }
            else
            {//None, 40bit, 56bit, 128bit, FIPS
                if (strRDPSecurityEncryptionMethod.Equals("None", StringComparison.CurrentCultureIgnoreCase))
                {
                    enMethod = EncryptionMethods.ENCRYPTION_METHOD_NONE;
                }
                else if (strRDPSecurityEncryptionMethod.Equals("40bit", StringComparison.CurrentCultureIgnoreCase))
                {
                    enMethod = EncryptionMethods.ENCRYPTION_METHOD_40BIT;
                }
                else if (strRDPSecurityEncryptionMethod.Equals("56bit", StringComparison.CurrentCultureIgnoreCase))
                {
                    enMethod = EncryptionMethods.ENCRYPTION_METHOD_56BIT;
                }
                else if (strRDPSecurityEncryptionMethod.Equals("128bit", StringComparison.CurrentCultureIgnoreCase))
                {
                    enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT;
                }
                else if (strRDPSecurityEncryptionMethod.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase))
                {
                    enMethod = EncryptionMethods.ENCRYPTION_METHOD_FIPS;
                }
                else
                {
                    assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod);
                }
            }

            if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE && enMethod != EncryptionMethods.ENCRYPTION_METHOD_NONE)
            {
                this.TestSite.Assume.Fail("When Encryption Level is set to None, the Encryption Method should also set to None.");
            }
            if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_FIPS && enMethod != EncryptionMethods.ENCRYPTION_METHOD_FIPS)
            {
                this.TestSite.Assume.Fail("When Encryption Level is set to FIPS, the Encryption Method should also set to FIPS.");
            }
            #endregion

            #region RDP Version
            rdpServerVersion = TS_UD_SC_CORE_version_Values.V2;

            #endregion

            #region WaitTime
            int waitSeconds;
            if (!PtfPropUtility.GetIntPtfProperty(TestSite, RdpPtfPropNames.Timeout, out waitSeconds))
            {
                assumeFailForInvalidPtfProp(RdpPtfPropNames.Timeout);
            }
            else
            {
                waitTime = new TimeSpan(0, 0, waitSeconds);
            }

            #endregion

            #region SUT Display Verification

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifySUTDisplay.Enable", out verifySUTDisplay))
            {
                verifySUTDisplay = false;
            }

            int shiftX, shiftY;
            if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.X", out shiftX))
            {
                shiftX = 0;
            }

            if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.Y", out shiftY))
            {
                shiftY = 0;
            }

            sutDisplayShift = new Point(shiftX, shiftY);

            if (!PtfPropUtility.GetStringPtfProperty(TestSite, "VerifySUTDisplay.BitmapSavePath", out bitmapSavePath))
            {
                bitmapSavePath = @".\";
            }

            // If the bitmap save path is not existed, create it.
            if (!Directory.Exists(bitmapSavePath))
            {
                Directory.CreateDirectory(bitmapSavePath);
            }

            #endregion SUT Display Verification

            #region Other configrations

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportFastPathInput, out isClientSupportFastPathInput))
            {
                isClientSupportFastPathInput = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportAutoReconnect, out isClientSuportAutoReconnect))
            {
                isClientSuportAutoReconnect = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRDPEFS, out isClientSupportRDPEFS))
            {
                isClientSupportRDPEFS = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportServerRedirection, out isClientSupportServerRedirection))
            {
                isClientSupportServerRedirection = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportSoftSync, out isClientSupportSoftSync))
            {
                isClientSupportSoftSync = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportTunnelingStaticVCTraffic, out isClientSupportTunnelingStaticVCTraffic))
            {
                isClientSupportTunnelingStaticVCTraffic = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRdpNegDataEmpty, out isClientSupportEmptyRdpNegData))
            {
                isClientSupportEmptyRdpNegData = false; //if property not found, set to false as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.IsWindowsImplementation, out isWindowsImplementation))
            {
                isWindowsImplementation = true; //if property not found, set to true as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.DropConnectionForInvalidRequest, out DropConnectionForInvalidRequest))
            {
                DropConnectionForInvalidRequest = true; //if property not found, set to true as default value
            }

            if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifyRdpbcgrMessage", out bVerifyRdpbcgrMessage))
            {
                bVerifyRdpbcgrMessage = true; //if property not found, set to true as default value
            }

            String rdprfxImageFile;
            if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFX.Image", out rdprfxImageFile))
            {
                rdprfxImageFile = ""; //if property not found, set to true as default value
            }

            String rdprfxVideoModeImageFile;
            if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFXVideoMode.Image", out rdprfxVideoModeImageFile))
            {
                rdprfxVideoModeImageFile = ""; //if property not found, set to true as default value
            }

            try
            {
                //Get image from file
                image_64X64       = Image.FromFile(rdprfxImageFile);
                imageForVideoMode = Image.FromFile(rdprfxVideoModeImageFile);
            }
            catch (System.IO.FileNotFoundException)
            {
                //capture screen if failed to get image from file
                //Capture 64*64 bitmap for Image Mode
                image_64X64 = captureScreenImage(0, 0, TileSize, TileSize);

                //Capture screen bitmap for Vedio Mode
                imageForVideoMode = captureScreenImage(0, 0, TileSize * VideoMode_TileRowNum, TileSize * VideoMode_TileColNum);
            }
            #endregion

            #endregion

            #region Logging
            this.TestSite.Log.Add(LogEntryKind.Debug,
                                  @"isClientSupportFastPathInput = {0};
                isClientSuportAutoReconnect = {1};
                isClientSupportRDPEFS = {2};
                isClientSupportServerRedirection = {3};
                isClientSupportEmptyRdpNegData = {4};
                isClientSupportSoftSync = {5}
                isClientSupportTunnelingStaticVCTraffic = {6}",
                                  isClientSupportFastPathInput,
                                  isClientSuportAutoReconnect,
                                  isClientSupportRDPEFS,
                                  isClientSupportServerRedirection,
                                  isClientSupportEmptyRdpNegData,
                                  isClientSupportSoftSync,
                                  isClientSupportTunnelingStaticVCTraffic);
            #endregion
        }
        /// <summary>
        /// Load configuration from PTF config file
        /// </summary>
        private void LoadConfiguation()
        {
            string tempStr;

            if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerName", out serverName))
            {
                AssumeFailForInvalidPtfProp("RDP.ServerName");
            }

            if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerDomain", out tempStr))
            {
                if (tempStr != null && tempStr.Length > 0)
                {
                    this.domain = tempStr;
                }
                else
                {
                    this.domain = this.serverName;
                }
            }

            if (!PtfPropUtility.GetIntPtfProperty(Site, "RDP.ServerPort", out serverPort))
            {
                AssumeFailForInvalidPtfProp("RDP.ServerPort");
            }

            if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerUserName", out userName))
            {
                AssumeFailForInvalidPtfProp("RDP.ServerUserName");
            }

            if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerUserPassword", out password))
            {
                AssumeFailForInvalidPtfProp("RDP.ServerUserPassword");
            }

            if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ClientName", out localAddress))
            {
                AssumeFailForInvalidPtfProp("RDP.ClientName");
            }

            int waitTime;

            if (!PtfPropUtility.GetIntPtfProperty(Site, "Timeout", out waitTime))
            {
                AssumeFailForInvalidPtfProp("Timeout");
            }
            timeout = new TimeSpan(0, 0, waitTime);

            if (!PtfPropUtility.GetIntPtfProperty(Site, "MultiTransportTimeout", out waitTime))
            {
                AssumeFailForInvalidPtfProp("MultiTransportTimeout");
            }
            multiTransportTimeout = new TimeSpan(0, 0, waitTime);

            PtfPropUtility.GetBoolPtfProperty(Site, "IsWindowsImplementation", out isWindowsImplementation);
            PtfPropUtility.GetBoolPtfProperty(Site, "VerifyRdpbcgrMessages", out verifyPduEnabled);
            PtfPropUtility.GetBoolPtfProperty(Site, "VerifyShouldBehaviors", out verifyShouldBehaviors);
            PtfPropUtility.GetBoolPtfProperty(Site, "RDPEDYCSupported", out isEDYCSupported);
            PtfPropUtility.GetBoolPtfProperty(Site, "RDPELESupported", out isELESupported);
            PtfPropUtility.GetBoolPtfProperty(Site, "IssueTemporaryLicenseForTheFirstTime", out issueTemporaryLicenseForTheFirstTime);

            if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.Version", out tempStr))
            {
                rdpVersion = new Version(tempStr);
            }
            else
            {
                AssumeFailForInvalidPtfProp("RDP.Version");
            }

            #region Security Approach and Protocol
            string strRDPSecurityProtocol;
            string strRDPSecurityTlsVersion;
            bool   isNegotiationBased = true;
            if (!PtfPropUtility.GetBoolPtfProperty(Site, "RDP.Security.Negotiation", out isNegotiationBased))
            {
                AssumeFailForInvalidPtfProp("RDP.Security.Negotiation");
            }

            requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG;
            if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.Security.Protocol", out strRDPSecurityProtocol))
            {
                AssumeFailForInvalidPtfProp("RDP.Security.Protocol");
            }

            //TLS, CredSSP, or RDP
            if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase))
            {
                if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.Security.TLS.Version", out strRDPSecurityTlsVersion))
                {
                    // TLS1.0, TLS1.1, TLS1.2 or None
                    if (strRDPSecurityTlsVersion.Equals("TLS1.0", StringComparison.CurrentCultureIgnoreCase))
                    {
                        tlsVersion = SslProtocols.Tls;
                    }
                    else if (strRDPSecurityTlsVersion.Equals("TLS1.1", StringComparison.CurrentCultureIgnoreCase))
                    {
                        tlsVersion = SslProtocols.Tls11;
                    }
                    else if (strRDPSecurityTlsVersion.Equals("TLS1.2", StringComparison.CurrentCultureIgnoreCase))
                    {
                        tlsVersion = SslProtocols.Tls12;
                    }
                    else if (strRDPSecurityTlsVersion.Equals("None", StringComparison.CurrentCultureIgnoreCase))
                    {
                        tlsVersion = SslProtocols.None;
                    }
                    else
                    {
                        this.Site.Log.Add(LogEntryKind.Comment, "TLS is used as security protocol and the TLS Version is {0}.", strRDPSecurityTlsVersion);
                        this.Site.Assume.Fail("When TLS is used as the security protocol, {0} must be one of TLS1.0, TLS1.1, or TLS1.2; actually it is set to {1}",
                                              "RDP.Security.TLS.Version",
                                              tlsVersion);
                    }
                }
                else
                {
                    AssumeFailForInvalidPtfProp("RDP.Security.TLS.Version");
                }

                requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG;
                this.Site.Assume.IsTrue(
                    isNegotiationBased,
                    "When TLS is used as the security protocol, {0} is set to 'TLS', {1} must be true.",
                    "RDP.Security.Protocol",
                    "RDP.Security.Negotiation");
                transportProtocol = EncryptedProtocol.NegotiationTls;
            }
            else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase))
            {
                requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG | requestedProtocols_Values.PROTOCOL_HYBRID_FLAG | requestedProtocols_Values.PROTOCOL_HYBRID_EX;
                if (isNegotiationBased)
                {
                    transportProtocol = EncryptedProtocol.NegotiationCredSsp;
                }
                else
                {
                    transportProtocol = EncryptedProtocol.DirectCredSsp;
                }
            }
            else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase))
            {
                requestProtocol   = requestedProtocols_Values.PROTOCOL_RDP_FLAG;
                transportProtocol = EncryptedProtocol.Rdp;
            }
            else
            {
                AssumeFailForInvalidPtfProp("RDP.Security.Protocol");
            }

            #endregion
        }