示例#1
0
        private void menuDeleteApp_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (MessageBox.Show(string.Format("确定删除应用程序\"{0}\"及下面的结构", this.tvApps.SelectedNode.Text),
                                    "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                string           appGuid = Convert.ToString(this.tvApps.SelectedNode.Tag);
                DeleteAppCommand cmd     = new DeleteAppCommand(AppService.Instance.GetApp(appGuid));
                cmd.RedoDone += new UndoRedoEventHandler(RemoveAppFromTree);
                cmd.UndoDone += new UndoRedoEventHandler(AddApp2Tree);

                cmd.Execute();

                AddCommand(cmd);
                RemoveAppFromTree(AppService.Instance.GetApp(appGuid));
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除新工艺失败,错误消息为:" + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        public void ShouldDeleteFromApi([Frozen] Mock <IAppHarborClient> appharborClient,
                                        [Frozen] Mock <IApplicationConfiguration> applicationConfiguration,
                                        DeleteAppCommand command,
                                        string id)
        {
            applicationConfiguration.Setup(x => x.GetApplicationId()).Returns(id);
            appharborClient.Setup(x => x.DeleteApplication(id));

            command.Execute(new string[0]);

            appharborClient.VerifyAll();
            applicationConfiguration.VerifyAll();
            applicationConfiguration.Verify(x => x.RemoveConfiguration());
        }