/// <summary> /// Initializes a new instance of the <see cref="CommandParser"/> class. /// </summary> /// <param name="game">The <see cref="MinesweeperGame"/> object for which commands will be returned.</param> public CommandParser(MinesweeperGame game) { if (game == null) { throw new ArgumentNullException(); } this.Game = game; // Create commands ICommand cmdRestart = new CmdRestart(game); ICommand cmdBoom = new CmdBoom(game); ICommand cmdShowScores = new CmdShowScores(game); ICommand cmdEndGame = new CmdExit(game); ICommand cmdInvalid = new CmdInvalid(game); this.commands = new Dictionary<string, ICommand>() { { "restart", cmdRestart }, { "top", cmdShowScores }, { "exit", cmdEndGame }, { "boom", cmdBoom }, { "invalid", cmdInvalid } }; }
/// <summary> /// Initializes a new instance of the <see cref="CommandParser"/> class. /// </summary> /// <param name="game">The <see cref="MinesweeperGame"/> object for which commands will be returned.</param> public CommandParser(MinesweeperGame game) { if (game == null) { throw new ArgumentNullException(); } this.Game = game; // Create commands ICommand cmdRestart = new CmdRestart(game); ICommand cmdBoom = new CmdBoom(game); ICommand cmdShowScores = new CmdShowScores(game); ICommand cmdEndGame = new CmdExit(game); ICommand cmdInvalid = new CmdInvalid(game); this.commands = new Dictionary <string, ICommand>() { { "restart", cmdRestart }, { "top", cmdShowScores }, { "exit", cmdEndGame }, { "boom", cmdBoom }, { "invalid", cmdInvalid } }; }
public void CmdExit_TrueWithNoArgs() { CmdExit _exit = new CmdExit(); string[] args = {}; var result = _exit.Validate(args); Assert.True(result, "Exit should return true with no arguments"); }
public void CmdExit_TrueWithMultipleArgs() { CmdExit _exit = new CmdExit(); string[] args = { "string1", "string2" }; var result = _exit.Validate(args); Assert.True(result, "Exit should return true with multiple arguments"); }
private void CmdSave_Click_1(object sender, EventArgs e) { try { if (txtConPW.Text == "") { MessageBox.Show("Please Enter the Valied Password! and Enter the same new password in comfirm password box!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNewPW.Focus(); txtNewPW.Text = ""; txtConPW.Text = ""; return; } if (txtOldPW.Text == lblOPW.Text && txtConPW.Text == txtNewPW.Text) { OleDbCommand cmd = new OleDbCommand("Update UserDetails SET Password1='" + txtNewPW.Text + "', PWHint='" + txtPHint.Text + "' WHERE UserID='" + txtUserID.Text + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Record Updated Sucessfully!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Information); CmdExit.Focus(); } else if (txtOldPW.Text != lblOPW.Text && txtConPW.Text != txtNewPW.Text) { MessageBox.Show("Please Try Again! Please Enter the Correct Old Password! and Enter the same new password in comfirm password box!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtOldPW.Focus(); txtNewPW.Text = ""; txtConPW.Text = ""; txtOldPW.Text = ""; } else if (txtOldPW.Text != lblOPW.Text) { MessageBox.Show("Please Enter the Correct Old Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtOldPW.Focus(); txtNewPW.Text = ""; txtOldPW.Text = ""; } else if (txtConPW.Text != txtNewPW.Text) { MessageBox.Show("Please Enter the Same Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtConPW.Focus(); txtConPW.Text = ""; } } catch (Exception x) { MessageBox.Show("ERROR CODE : CMD-SAV-309-PSW" + "\n" + "\n" + "[Please Note this Error Code and Take a Photo in this More Details." + "\n" + "\n" + "Inform the Error Code and Send this Error Details (Mail or WhatsUP) to Development Team (SRIS)!]" + "\n" + "\n" + "\n" + "MORE DETAILS :- " + "\n" + "\n" + x, "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { try { MemoryStream ms = new MemoryStream(); PicImg.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] Photo = new byte[ms.Length]; ms.Position = 0; ms.Read(Photo, 0, Photo.Length); OleDbCommand cmd = new OleDbCommand("Update UserDetails SET BGColor='" + txtCol.Text + "', IImg=@photo WHERE UserID='" + txtUserID.Text + "'", con); cmd.Parameters.AddWithValue("@photo", Photo); con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Record Updated Sucessfully!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Information); CmdExit.Focus(); } catch (Exception) { MessageBox.Show(" Error No:PWCS01 Please Select Valied Profile Photo", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Test_CmdExit_CtorWithNullThrowsEx() { var cmd = new CmdExit(null); }