Ejemplo n.º 1
0
        /// <summary>
        /// This method is used to initialize the share test case helper. This method will also initialize all helpers which are required to initialize during test suite running.
        /// </summary>
        /// <param name="siteInstance">A parameter represents the ITestSite instance.</param>
        public static void InitializeHelper(ITestSite siteInstance)
        {
            TestSuiteHelper.CheckInputParameterNullOrEmpty <ITestSite>(siteInstance, "siteInstance", "InitializeHelper");

            if (string.IsNullOrEmpty(currentTestClientName))
            {
                currentTestClientName = Common.GetConfigurationPropertyValue("TestClientName", siteInstance);
            }

            if (null == wopiSutControlAdapter)
            {
                wopiSutControlAdapter = siteInstance.GetAdapter <IMS_WOPISUTControlAdapter>();
            }

            if (null == wopiSutManagedCodeControlAdapter)
            {
                wopiSutManagedCodeControlAdapter = siteInstance.GetAdapter <IMS_WOPIManagedCodeSUTControlAdapter>();
            }

            if (null == wopiProtocolAdapter)
            {
                wopiProtocolAdapter = siteInstance.GetAdapter <IMS_WOPIAdapter>();
            }

            InitializeRequiredHelpers(wopiSutManagedCodeControlAdapter, siteInstance);

            if (string.IsNullOrEmpty(relativeSourceFileUrl))
            {
                relativeSourceFileUrl = Common.GetConfigurationPropertyValue("NormalFile", siteInstance);
            }

            progId = Common.GetConfigurationPropertyValue("ProgIdForDiscoveryProcess", siteInstance);

            // Setting the endpoint name according to the current http transport.
            if (string.IsNullOrEmpty(currentSharedTestCasesEndpointName))
            {
                TransportProtocol currentTransport = Common.GetConfigurationPropertyValue <TransportProtocol>("TransportType", siteInstance);
                switch (currentTransport)
                {
                case TransportProtocol.HTTP:
                {
                    currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTP", siteInstance);
                    break;
                }

                case TransportProtocol.HTTPS:
                {
                    currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTPS", siteInstance);
                    break;
                }

                default:
                {
                    throw new InvalidOperationException(string.Format("The test suite only support HTTP or HTTPS transport. Current:[{0}]", currentTransport));
                }
                }
            }

            // Set the protocol name of current test suite
            siteInstance.DefaultProtocolDocShortName = WopiProtocolShortName;

            hasInitializedHelperStatus = true;
        }
        /// <summary>
        /// This method is used to initialize the share test case helper. This method will also initialize all helpers which are required to initialize during test suite running.
        /// </summary>
        /// <param name="siteInstance">A parameter represents the ITestSite instance.</param>
        public static void InitializeHelper(ITestSite siteInstance)
        {
            TestSuiteHelper.CheckInputParameterNullOrEmpty<ITestSite>(siteInstance, "siteInstance", "InitializeHelper");

            if (string.IsNullOrEmpty(currentTestClientName))
            {
                currentTestClientName = Common.GetConfigurationPropertyValue("TestClientName", siteInstance);
            }

            if (null == wopiSutControlAdapter)
            {
                wopiSutControlAdapter = siteInstance.GetAdapter<IMS_WOPISUTControlAdapter>();
            }

            if (null == wopiSutManagedCodeControlAdapter)
            {
                wopiSutManagedCodeControlAdapter = siteInstance.GetAdapter<IMS_WOPIManagedCodeSUTControlAdapter>();
            }

            if (null == wopiProtocolAdapter)
            {
                wopiProtocolAdapter = siteInstance.GetAdapter<IMS_WOPIAdapter>();
            }

            InitializeRequiredHelpers(wopiSutManagedCodeControlAdapter, siteInstance);

            if (string.IsNullOrEmpty(relativeSourceFileUrl))
            {
                relativeSourceFileUrl = Common.GetConfigurationPropertyValue("NormalFile", siteInstance);
            }

            progId = Common.GetConfigurationPropertyValue("ProgIdForDiscoveryProcess", siteInstance);

            // Setting the endpoint name according to the current http transport.
            if (string.IsNullOrEmpty(currentSharedTestCasesEndpointName))
            {
                TransportProtocol currentTransport = Common.GetConfigurationPropertyValue<TransportProtocol>("TransportType", siteInstance);
                switch (currentTransport)
                {
                    case TransportProtocol.HTTP:
                        {
                            currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTP", siteInstance);
                            break;
                        }

                    case TransportProtocol.HTTPS:
                        {
                            currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTPS", siteInstance);
                            break;
                        }

                    default:
                        {
                            throw new InvalidOperationException(string.Format("The test suite only support HTTP or HTTPS transport. Current:[{0}]", currentTransport));
                        }
                }
            }

            // Set the protocol name of current test suite
            siteInstance.DefaultProtocolDocShortName = WopiProtocolShortName;

            hasInitializedHelperStatus = true;
        }