Пример #1
0
 /// <summary>
 /// A method is used to initialize all required helpers when calling the SharedCase helper. Normally, all this method will try to initial all helpers which are required to initialize.
 /// </summary>
 ///  <param name="sutManagedCodeControlAdpater">A parameter represents the IMS_WOPISUTManageCodeControlAdapter instance which is used to convert the normal resource URL to WOPI format URL.</param>
 /// <param name="siteInstance">A parameter represents the ITestSite instance.</param>
 private static void InitializeRequiredHelpers(IMS_WOPIManagedCodeSUTControlAdapter sutManagedCodeControlAdpater, ITestSite siteInstance)
 {
     if (!TokenAndRequestUrlHelper.HasInitialized)
     {
         TokenAndRequestUrlHelper.InitializeHelper(sutManagedCodeControlAdpater, siteInstance);
     }
 }
        /// <summary>
        /// A method is used to initialize the TokenAndRequestUrlHelper helper.
        /// </summary>
        /// <param name="managedCodeSutConrollerAdapterInstance">A parameter represents the IMS_WOPISUTManageCodeControlAdapter type instance, it is used to get WOPI root resource URL.</param>
        /// <param name="testSiteInstance">A parameter represents an ITestSite instance which is used to get test suite context.</param>
        public static void InitializeHelper(IMS_WOPIManagedCodeSUTControlAdapter managedCodeSutConrollerAdapterInstance, ITestSite testSiteInstance)
        {
            HelperBase.CheckInputParameterNullOrEmpty<IMS_WOPIManagedCodeSUTControlAdapter>(managedCodeSutConrollerAdapterInstance, "managedCodeSutConrollerAdapterInstance", "InitializeHelper");
            HelperBase.CheckInputParameterNullOrEmpty<ITestSite>(testSiteInstance, "testSiteInstance", "InitializeHelper");

            if (!hasInitializedTokenAndRequestUrlHelper)
            {
                if (string.IsNullOrEmpty(DefaultUserName))
                {
                    DefaultUserName = Common.GetConfigurationPropertyValue("UserName", testSiteInstance);
                    DefaultDomain = Common.GetConfigurationPropertyValue("Domain", testSiteInstance);
                    DefaultPassword = Common.GetConfigurationPropertyValue("Password", testSiteInstance);
                }

                if (null == currentTestSite)
                {
                    currentTestSite = testSiteInstance;
                }

                CurrentHttpTransport = Common.GetConfigurationPropertyValue<TransportProtocol>("TransportType", testSiteInstance);
                hasInitializedTokenAndRequestUrlHelper = true;
            }
        }
        /// <summary>
        /// A method is used to initialize the TokenAndRequestUrlHelper helper.
        /// </summary>
        /// <param name="managedCodeSutConrollerAdapterInstance">A parameter represents the IMS_WOPISUTManageCodeControlAdapter type instance, it is used to get WOPI root resource URL.</param>
        /// <param name="testSiteInstance">A parameter represents an ITestSite instance which is used to get test suite context.</param>
        public static void InitializeHelper(IMS_WOPIManagedCodeSUTControlAdapter managedCodeSutConrollerAdapterInstance, ITestSite testSiteInstance)
        {
            HelperBase.CheckInputParameterNullOrEmpty <IMS_WOPIManagedCodeSUTControlAdapter>(managedCodeSutConrollerAdapterInstance, "managedCodeSutConrollerAdapterInstance", "InitializeHelper");
            HelperBase.CheckInputParameterNullOrEmpty <ITestSite>(testSiteInstance, "testSiteInstance", "InitializeHelper");

            if (!hasInitializedTokenAndRequestUrlHelper)
            {
                if (string.IsNullOrEmpty(DefaultUserName))
                {
                    DefaultUserName = Common.GetConfigurationPropertyValue("UserName", testSiteInstance);
                    DefaultDomain   = Common.GetConfigurationPropertyValue("Domain", testSiteInstance);
                    DefaultPassword = Common.GetConfigurationPropertyValue("Password", testSiteInstance);
                }

                if (null == currentTestSite)
                {
                    currentTestSite = testSiteInstance;
                }

                CurrentHttpTransport = Common.GetConfigurationPropertyValue <TransportProtocol>("TransportType", testSiteInstance);
                hasInitializedTokenAndRequestUrlHelper = true;
            }
        }
Пример #4
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>
 /// A method is used to initialize all required helpers when calling the SharedCase helper. Normally, all this method will try to initial all helpers which are required to initialize.  
 /// </summary>
 ///  <param name="sutManagedCodeControlAdpater">A parameter represents the IMS_WOPISUTManageCodeControlAdapter instance which is used to convert the normal resource URL to WOPI format URL.</param>
 /// <param name="siteInstance">A parameter represents the ITestSite instance.</param>
 private static void InitializeRequiredHelpers(IMS_WOPIManagedCodeSUTControlAdapter sutManagedCodeControlAdpater, ITestSite siteInstance)
 {
     if (!TokenAndRequestUrlHelper.HasInitialized)
     {
         TokenAndRequestUrlHelper.InitializeHelper(sutManagedCodeControlAdpater, siteInstance);
     }
 }
        /// <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;
        }