Example #1
0
 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);
     }
 }
Example #2
0
        public void CanAddAndRetrieveAnElement()
        {
            var list = new MostRecentList <string>();

            list.AddUsage("a");
            CollectionAssert.AreEqual(new[] { "a" }, list.GetMostRecentValues());
        }
Example #3
0
        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());
        }
Example #4
0
        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());
        }
Example #5
0
        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());
        }
Example #6
0
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     MostRecentList.Save(AppPaths.RecentDecksFilePath, _recentDecks);
     FavouritesList.Save(AppPaths.FavouritessFilePath, _favourites);
 }