예제 #1
0
        public void GetAll_ReturnsAllwordObjects_wordList()
        {
            WordCounter.ClearAll();
            //Arrange
            string             name1           = "test";
            string             name2           = "newtest";
            WordCounter        newWordCounter1 = new WordCounter(name1, name2);
            WordCounter        newWordCounter  = new WordCounter(name1, name2);
            List <WordCounter> newList         = new List <WordCounter> {
                newWordCounter1, newWordCounter
            };
            //Act
            List <WordCounter> result = WordCounter.GetAll();

            Console.WriteLine("how many items" + result.Count);
            //Assert
            CollectionAssert.AreEqual(newList, result);
        }
예제 #2
0
        public void GetAll_ReturnsAllWordCounterObjects_WordCounterList()
        {
            //Arrange
            string             word1           = "Work";
            string             sentence1       = "I love my Work";
            string             word2           = "Happy";
            string             sentence2       = "Happy days";
            WordCounter        newWordCounter1 = new WordCounter(word1, sentence1);
            WordCounter        newWordCounter2 = new WordCounter(word2, sentence2);
            List <WordCounter> newList         = new List <WordCounter> {
                newWordCounter1, newWordCounter2
            };

            //Act
            List <WordCounter> result = WordCounter.GetAll();

            //Assert
            CollectionAssert.AreEqual(newList, result);
        }
        public ActionResult Create(string wordInput, string sentenceInput)
        {
            WordCounter newWordCounter = new WordCounter(wordInput, sentenceInput);

            if (newWordCounter.IsInputValid(wordInput) == false)
            {
                newWordCounter.ErrorMessage = "Please Enter A Word!!!";
                List <WordCounter> allWordCounters = WordCounter.GetAll();
                //removes last word passed through form that was invalid:
                allWordCounters.RemoveAt(allWordCounters.Count - 1);
                return(RedirectToAction("New", allWordCounters));
            }
            else
            {
                newWordCounter.CheckIfWordMatchSentence();
                List <WordCounter> allWordCounters = WordCounter.GetAll();
                return(RedirectToAction("Index", allWordCounters));
            }
        }
예제 #4
0
        public ActionResult Index()
        {
            List <WordCounter> allWordCounter = WordCounter.GetAll();

            return(View(allWordCounter));
        }