public void TestOnFlowFinished_ResetsValues()
        {
            _objectUnderTest.DeploymentVersion = "test-deployment-version";
            _objectUnderTest.DeploymentName    = "test-deployment-name";
            _objectUnderTest.Replicas          = "200";
            _objectUnderTest.RefreshClustersListCommand.CanExecuteCommand = true;
            _objectUnderTest.CreateClusterCommand.CanExecuteCommand       = true;

            _objectUnderTest.OnFlowFinished();

            Assert.AreEqual(GcpPublishStepsUtils.GetDefaultVersion(), _objectUnderTest.DeploymentVersion);
            Assert.IsNull(_objectUnderTest.DeploymentName);
            Assert.AreEqual(GkeStepViewModel.ReplicasDefaultValue, _objectUnderTest.Replicas);
            Assert.IsFalse(_objectUnderTest.RefreshClustersListCommand.CanExecuteCommand);
            Assert.IsFalse(_objectUnderTest.CreateClusterCommand.CanExecuteCommand);
        }
Exemplo n.º 2
0
        private bool ValidateInput()
        {
            if (String.IsNullOrEmpty(Version))
            {
                UserPromptUtils.ErrorPrompt(Resources.FlexPublishEmptyVersionMessage, Resources.UiInvalidValueTitle);
                return(false);
            }
            if (!GcpPublishStepsUtils.IsValidName(Version))
            {
                UserPromptUtils.ErrorPrompt(
                    String.Format(Resources.FlexPublishInvalidVersionMessage, Version),
                    Resources.UiInvalidValueTitle);
                return(false);
            }

            return(true);
        }
        private bool ValidateInput()
        {
            int replicas;

            if (!int.TryParse(Replicas, out replicas))
            {
                UserPromptUtils.ErrorPrompt(Resources.GkePublishInvalidReplicasMessage, Resources.UiInvalidValueTitle);
                return(false);
            }

            if (String.IsNullOrEmpty(DeploymentName))
            {
                UserPromptUtils.ErrorPrompt(Resources.GkePublishEmptyDeploymentNameMessage, Resources.UiInvalidValueTitle);
                return(false);
            }

            if (!GcpPublishStepsUtils.IsValidName(DeploymentName))
            {
                UserPromptUtils.ErrorPrompt(
                    String.Format(Resources.GkePublishInvalidDeploymentNameMessage, DeploymentName),
                    Resources.UiInvalidValueTitle);
                return(false);
            }
            if (String.IsNullOrEmpty(DeploymentVersion))
            {
                UserPromptUtils.ErrorPrompt(Resources.GkePublishEmptyDeploymentVersionMessage, Resources.UiInvalidValueTitle);
                return(false);
            }
            if (!GcpPublishStepsUtils.IsValidName(DeploymentVersion))
            {
                UserPromptUtils.ErrorPrompt(
                    String.Format(Resources.GkePublishInvalidDeploymentVersionMessage, DeploymentVersion),
                    Resources.UiInvalidValueTitle);
                return(false);
            }

            return(true);
        }
        private async Task InitializeDialogState()
        {
            try
            {
                // Mark that the project is being loaded and verified.
                LoadingProject = true;

                if (string.IsNullOrEmpty(DeploymentName))
                {
                    DeploymentName = PublishDialog.Project.Name.ToLower();
                }
                if (string.IsNullOrEmpty(DeploymentVersion))
                {
                    DeploymentVersion = GcpPublishStepsUtils.GetDefaultVersion();
                }

                Task <bool> validateTask = ValidateGcpProjectState();
                PublishDialog.TrackTask(validateTask);

                if (await validateTask)
                {
                    Task <IEnumerable <Cluster> > clustersTask = GetAllClustersAsync();
                    PublishDialog.TrackTask(clustersTask);
                    Clusters = await clustersTask;
                }
            }
            catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex))
            {
                CanPublish   = false;
                GeneralError = true;
            }
            finally
            {
                LoadingProject = false;
            }
        }
        public void TestToValid_NameChange(string invalidName, string expectedResult)
        {
            string result = GcpPublishStepsUtils.ToValidName(invalidName);

            Assert.AreEqual(expectedResult, result);
        }
        public void TestToValid_NameUnchanged(string unchangingName)
        {
            string result = GcpPublishStepsUtils.ToValidName(unchangingName);

            Assert.AreEqual(unchangingName, result);
        }
        public void TestValidateServiceName_IsEmptyForValidString()
        {
            IEnumerable<ValidationResult> results = GcpPublishStepsUtils.ValidateServiceName("valid-service-name", FieldName);

            CollectionAssert.That.IsEmpty(results);
        }
 public void TestIsDefaultVersion_False(string version)
 {
     Assert.IsFalse(GcpPublishStepsUtils.IsDefaultVersion(version));
 }