public void EveryWeekTest() { Mytime test = new Mytime(); //找到每一年头一个星期一的日期数 //2019年 Assert.AreEqual(new DateTime(2019, 1, 7), new DateTime(2019, 1, test.FristMonday(2019))); Assert.AreEqual(7, test.FristMonday(2019)); //2020年 Assert.AreEqual(new DateTime(2020, 1, 6), new DateTime(2020, 1, test.FristMonday(2020))); }
// This function including necessary procedures of new game load. private void SetGame() { GameBoard.Visible = true; textBox1.Visible = false; GameBoard.Controls.Clear(); theController.InitGameData(); this.GameBoardDisplay(); this.GameValueDisplay(theController.sudokuString); SetClicks(); Mytime.Start(); Mytime.Tag = "Open"; timeTicks = 0; theController.ClearSteps(); }
public void GetDayTest() { Mytime test = new Mytime(); //几天后 , Assert.AreEqual(new DateTime(2020, 4, 6), test.GetDate(new DateTime(2020, 4, 1), 5, Mytime.unit.day)); //几十天后,跨月 Assert.AreEqual(new DateTime(2020, 5, 1), test.GetDate(new DateTime(2020, 4, 1), 30, Mytime.unit.day)); //几百天后,跨年 Assert.AreEqual(new DateTime(2021, 4, 1), test.GetDate(new DateTime(2020, 4, 1), 365, Mytime.unit.day)); //1个星期后 Assert.AreEqual(new DateTime(2020, 4, 8), test.GetDate(new DateTime(2020, 4, 1), 1, Mytime.unit.week)); //几个星期后 Assert.AreEqual(new DateTime(2020, 4, 22), test.GetDate(new DateTime(2020, 4, 1), 3, Mytime.unit.week)); //几个月后 Assert.AreEqual(new DateTime(2020, 7, 1), test.GetDate(new DateTime(2020, 4, 1), 3, Mytime.unit.month)); //十几个月后,跨年 Assert.AreEqual(new DateTime(2021, 3, 1), test.GetDate(new DateTime(2020, 4, 1), 11, Mytime.unit.month)); }
//--------- game button functions ------- // Pause the game by menu bar. private void PauseToolStripMenuItem_Click(object sender, EventArgs e) { if (gameSelect != null && gameSelect != "") { if ((string)Mytime.Tag == "Open") { Mytime.Stop(); Mytime.Tag = "Close"; GameBoard.Visible = false; PauseButton.Text = "Continue"; pauseToolStripMenuItem.Text = "Continue"; } else { Mytime.Start(); Mytime.Tag = "Open"; GameBoard.Visible = true; PauseButton.Text = "Pause"; pauseToolStripMenuItem.Text = "Pause"; } } }
// Display Win information. private void WinInfoDisplay() { string username; TextBox c = new TextBox(); c.Font = new Font("Microsoft Sans Serif", 15); c.Text = "You win!! \n" + "Your Score is: " + theController.GetGameScore(minutes, seconds); c.ForeColor = Color.LightCoral; c.Visible = true; c.Location = new Point(50, 200); c.Size = new Size(400, 96); c.TextAlign = HorizontalAlignment.Center; GameBoard.Controls.Clear(); GameBoard.Controls.Add(c); Mytime.Stop(); ScoreMessage.Visible = true; username = ShowDialog("Please enter your name:", "username"); username = username.Replace(",", string.Empty); username = username == "" ? "No name" : username; ScoreMessage.Text = theController.ScoreList(username, theController.GetGameScore(minutes, seconds)); }