Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Update the name when the data changes.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_txtProjName_TextChanged(object sender, EventArgs e)
        {
            // If the project name is unchanged (or changed back), don't check for validity. (This will allow users who have already
            // given their projects non-ASCII names to change other project properties without having to change their project names)
            if (!OriginalProjectName.Equals(m_txtProjName.Text))
            {
                string errorMessage;
                var    projectName = m_txtProjName.Text;
                if (!FwNewLangProjectModel.CheckForSafeProjectName(ref projectName, out errorMessage))
                {
                    MessageBox.Show(errorMessage, FwCoreDlgs.FwProjProperties_PickDifferentProjName, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    m_txtProjName.TextChanged -= m_txtProjName_TextChanged;
                    m_txtProjName.Text         = projectName;
                    m_txtProjName.TextChanged += m_txtProjName_TextChanged;
                }

                if (!FwNewLangProjectModel.CheckForUniqueProjectName(projectName))
                {
                    MessageBox.Show(string.Format(FwCoreDlgs.FwProjProperties_DuplicateProjectName, projectName, OriginalProjectName),
                                    FwCoreDlgs.FwProjProperties_PickDifferentProjName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            m_btnOK.Enabled = m_txtProjName.Text.Trim().Length > 0 &&
                              (OriginalProjectName.Equals(m_txtProjName.Text) || FwNewLangProjectModel.CheckForUniqueProjectName(m_txtProjName.Text));
            m_lblProjName.Text = m_txtProjName.Text;
        }
Exemple #2
0
        public void FwNewLangProjectModel_ProjectNameIsUnique()
        {
            try
            {
                CreateDb(DbName);
                string errorMessage;
                Assert.True(FwNewLangProjectModel.CheckForUniqueProjectName("something else"), "unique name should be unique");
                Assert.False(FwNewLangProjectModel.CheckForUniqueProjectName(DbName), "duplicate name should not be unique");

                // Creating a new project is expensive (several seconds), so test this property that also checks uniqueness here:
                var testModel = new FwNewLangProjectModel
                {
                    LoadProjectNameSetup = () => { },
                    ProjectName          = "something new"
                };
                Assert.True(testModel.IsProjectNameValid, "unique name should be valid");
                testModel.ProjectName = DbName;
                Assert.False(testModel.IsProjectNameValid, "duplicate name should not be valid");
            }
            finally
            {
                // Blow away the database to clean things up
                DestroyDb(DbName, false);
            }
        }