public void TestConversionToGame() { string time = DateTime.UtcNow.ToString(); string[] values = new string[] { "Player", "Opponent", "Stage", "Win", time }; ListViewItem item = new ListViewItem(values); Game game1 = new Game() { player = "Player", opponent = "Opponent", stage = "Stage", result = Result.Win, timeStamp = time }; Game game2 = GameConverter.ItemToGame(item); Assert.AreEqual(game1, game2); }
protected override void OnFormClosing(FormClosingEventArgs e) { history.games = new List <Game>(); foreach (ListViewItem i in historyList.Items) { history.games.Add(GameConverter.ItemToGame(i)); } history.Save(); base.OnFormClosing(e); }
public void TestConversion() { Game game1 = new Game() { player = "Player", opponent = "Opponent", stage = "Stage", result = Result.Win, timeStamp = DateTime.UtcNow.ToString() }; ListViewItem item = GameConverter.GameToItem(game1); Game game2 = GameConverter.ItemToGame(item); Assert.AreEqual(game1, game2); }
private void EditButton_Click(object sender, EventArgs e) { if (historyList.SelectedItems.Count <= 0) { return; } Game g = GameConverter.ItemToGame(historyList.SelectedItems[0]); EditDialog dialog = new EditDialog(g); if (dialog.ShowDialog() == DialogResult.OK) { int index = historyList.SelectedIndices[0]; ListViewItem item = GameConverter.GameToItem(dialog.ReturnValue); historyList.Items.Remove(historyList.SelectedItems[0]); historyList.Items.Insert(index, item); PopulateStatisticListView(); } }