Esempio n. 1
0
        public void Dialog_WhenClosedWithoutClickingOK_LeavesConfigsUnchanged()
        {
            dlg.ConfigurationName.Text = "New";
            dlg.Close();

            Assert.That(model.ConfigNames, Is.EqualTo(new[] { "Debug", "Release" }));
        }
Esempio n. 2
0
        public RenameConfigurationPresenter(IPropertyModel model, IRenameConfigurationDialog dlg, string originalName)
        {
            this.model        = model;
            this.dlg          = dlg;
            this.originalName = originalName;

            dlg.ConfigurationName.Text = originalName;
            dlg.ConfigurationName.Select(0, originalName.Length);

            dlg.ConfigurationName.Changed += delegate
            {
                string text = dlg.ConfigurationName.Text;
                dlg.OkButton.Enabled = text != string.Empty && text != originalName;
            };

            dlg.OkButton.Execute += delegate
            {
                string newName = dlg.ConfigurationName.Text;

                foreach (string existingName in model.ConfigNames)
                {
                    if (existingName == newName)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                model.Configs[originalName].Name = newName;

                if (model.ActiveConfigName == originalName)
                {
                    model.ActiveConfigName = newName;
                }

                dlg.Close();
            };
        }
        public RenameConfigurationPresenter(IPropertyModel model, IRenameConfigurationDialog dlg, string originalName)
        {
            this.model = model;
            this.dlg = dlg;
            this.originalName = originalName;

            dlg.ConfigurationName.Text = originalName;
            dlg.ConfigurationName.Select(0, originalName.Length);

            dlg.ConfigurationName.Changed += delegate
            {
                string text = dlg.ConfigurationName.Text;
                dlg.OkButton.Enabled = text != string.Empty && text != originalName;
            };

            dlg.OkButton.Execute += delegate
            {
                string newName = dlg.ConfigurationName.Text;

                foreach (string existingName in model.ConfigNames)
                {
                    if (existingName == newName)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                model.Configs[originalName].Name = newName;

                if (model.ActiveConfigName == originalName)
                    model.ActiveConfigName = newName;

                dlg.Close();
            };
        }