Пример #1
0
        /// <summary>
        /// on test setup
        /// the derived class could use it to run it owned set up settings.
        /// </summary>
        public virtual void OnTestSetup()
        {
            if (isResourceMode)
            {
                if (!isLogin)
                {
                    if (Utility.GetAutoLogin())
                    {
                        int retry = 0;
                        do
                        {
                            if (CommandAgent.HadErrors)
                            {
                                Thread.Sleep(5000);
                                Test.Info(string.Format("Retry login... Count:{0}", retry));
                            }
                            if (!TestContext.FullyQualifiedTestClassName.Contains("SubScriptionBVT")) //For SubScriptionBVT, we already login and set current account, don't need re-login
                            {
                                CommandAgent.Logout();
                                CommandAgent.Login();
                            }
                        }while (CommandAgent.HadErrors && retry++ < 5);
                    }

                    if (lang == Language.NodeJS)
                    {
                        SetActiveSubscription();
                        CommandAgent.ChangeCLIMode(Constants.Mode.arm);
                    }

                    isLogin = true;
                }
            }
            else
            {
                if (!accountImported)
                {
                    if (lang == Language.NodeJS)
                    {
                        NodeJSAgent nodeAgent = (NodeJSAgent)CommandAgent;
                        nodeAgent.Logout();
                        nodeAgent.ChangeCLIMode(Constants.Mode.asm);
                    }

                    string settingFile    = Test.Data.Get("AzureSubscriptionPath");
                    string subscriptionId = Test.Data.Get("AzureSubscriptionID");
                    CommandAgent.ImportAzureSubscription(settingFile);

                    string subscriptionID = Test.Data.Get("AzureSubscriptionID");
                    CommandAgent.SetActiveSubscription(subscriptionID);

                    accountImported = true;
                }
            }
        }