Example #1
0
        public IActionResult CreateTemplate()
        {
            TextReader cardsetTemplate =
                new StreamReader(
                    Path.Combine(
                        AppDomain.CurrentDomain.BaseDirectory,
                        "SlippingCards_template.txt"));
            var cardset = CardsetLoaderHelper.LoadCardset(cardsetTemplate.ReadToEnd());

            return(View("Create", cardset));
        }
Example #2
0
 public IActionResult Create(CardLoaderViewModel cardsetData)
 {
     try
     {
         var cardset = CardsetLoaderHelper.LoadCardset(cardsetData.CardSetText);
         return(View(cardset));
     }
     catch (Exception ex)
     {
         return(View("HowToUseIt"));
     }
 }
Example #3
0
        public void CreateSectionFromTextNoCard_AssertOneSectionCreated_ReturnsTrue()
        {
            var text    = "This is a section\n----";
            var cardset = CardsetLoaderHelper.LoadCardset(text);

            int howManySectionsWhereCreated = 0;

            if (cardset.Sections.Count != 1)
            {
                Assert.Fail("There were more sections than expected.");
            }
            foreach (var section in cardset.Sections)
            {
                if (section.Title == "This is a section")
                {
                    howManySectionsWhereCreated++;
                }
            }

            Assert.AreEqual(howManySectionsWhereCreated, 1);
        }
Example #4
0
        public void CreateSectionFromTextWithTrailinChars_AssertOneSectionCreated_ReturnsTrue()
        {
            // Oops, we slipped a card in a place that it shouldn't be. No \n after the hyphens.
            var text    = "This is a section\n----This is a card: Should not be here.";
            var cardset = CardsetLoaderHelper.LoadCardset(text);

            int howManySectionsWhereCreated = 0;

            if (cardset.Sections.Count != 1)
            {
                Assert.Fail("There were more sections than expected.");
            }
            foreach (var section in cardset.Sections)
            {
                if (section.Title == "This is a section")
                {
                    howManySectionsWhereCreated++;
                }
            }

            Assert.AreEqual(howManySectionsWhereCreated, 1);
        }
Example #5
0
        public void CreateCardsetFromFile_AssertSectionsAndCardsCountEquals_ReturnsTrue()
        {
            TextReader textReader      = new StreamReader("SlippingCards_template.txt");
            var        cardSet         = CardsetLoaderHelper.LoadCardset(textReader.ReadToEnd());
            var        cardSetTemplate = GetTemplateCardset();

            const int totalSections = 3;
            const int totalCards    = 23;


            int sectionsCount = cardSet.Sections.Count;

            int cardsCount = 0;

            foreach (var section in cardSet.Sections)
            {
                cardsCount += section.Cards.Count;
            }


            Assert.AreEqual(sectionsCount, totalSections);
            Assert.AreEqual(cardsCount, totalCards);
        }