private void Initialize() { try { _correctCardNames.Initialize(); } catch (IOException) { FatalError($"IO Error reading {CorrectCardNames.FileName}"); } catch (InvalidOperationException) { FatalError($"{CorrectCardNames.FileName} contains invalid entries."); } InitializeTemplate(); try { _recentDecks = MostRecentList.Read(AppPaths.RecentDecksFilePath); } catch (IOException ex) { _recentDecks = new MostRecentList(); ShowError("There was an error while loading recent decks.\r\n" + ex.Message); } try { _favourites = FavouritesList.Read(AppPaths.FavouritessFilePath); } catch (IOException ex) { _favourites = new FavouritesList(); ShowError("There was an error while loading favourite decks.\r\n" + ex.Message); } }
public void CanAddAndRetrieveAnElement() { var list = new MostRecentList <string>(); list.AddUsage("a"); CollectionAssert.AreEqual(new[] { "a" }, list.GetMostRecentValues()); }
public void DuplicateAddsOnlyReturnedOnce() { var list = new MostRecentList <string>(3); list.AddUsage("c"); list.AddUsage("d"); list.AddUsage("e"); list.AddUsage("d"); CollectionAssert.AreEqual(new[] { "d", "e", "c" }, list.GetMostRecentValues()); }
public void ExcessElementsAreRemoved() { var list = new MostRecentList <string>(3); list.AddUsage("a"); list.AddUsage("b"); list.AddUsage("c"); list.AddUsage("d"); list.AddUsage("e"); CollectionAssert.AreEqual(new[] { "e", "d", "c" }, list.GetMostRecentValues()); }
public void ElementsReturnedInReverseOrderOfAdding() { var list = new MostRecentList <string>(); list.AddUsage("a"); list.AddUsage("b"); list.AddUsage("c"); list.AddUsage("d"); list.AddUsage("e"); CollectionAssert.AreEqual(new[] { "e", "d", "c", "b", "a" }, list.GetMostRecentValues()); }
private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { MostRecentList.Save(AppPaths.RecentDecksFilePath, _recentDecks); FavouritesList.Save(AppPaths.FavouritessFilePath, _favourites); }