/// <summary> /// This program runs in the terminal. It outputs text to the student. /// </summary> static void Main() { WriteLine("Welcome to Remember the Letter (C# object-oriented)"); WriteLine(); // blank line WriteLine("Enter 'open' if you want to open a lesson file"); WriteLine("Enter 'opendb' if you want to open a lesson from a database."); WriteLine("Enter 'n' if you want to create a new lesson."); WriteLine(); PrintPrompt(); string userInput = ReadLine(); if (userInput == "open") { WriteLine("Enter a name for a file to open:"); PrintPrompt(); string fileName = ReadLine(); string fileContents = File.ReadAllText(fileName); IList <Flashcard> flashcards = Lesson.FromTabSeparatedValues(fileContents); Lesson.PopulateID(flashcards); // needed for deletion to work. StartCommandLineLoop(flashcards, false); } else if (userInput == "opendb") { IList <Flashcard> flashcards = LoadFromDatabase(); StartCommandLineLoop(flashcards, true); } else { StartCommandLineLoop(new List <Flashcard>(), false); } }
public void FromTabSeparatedValues_WhenGivenThreeWellFormedLines_ReturnsAThreeElementList() { IList <Flashcard> flashcards = Lesson.FromTabSeparatedValues("a\tb\nc\td\ne\tf\n"); Assert.That(flashcards.Count, Is.EqualTo(3)); }
public void FromTabSeparatedValues_WhenGivenAnEmptyString_ReturnsAnEmptyList() { IList <Flashcard> flashcards = Lesson.FromTabSeparatedValues(string.Empty); Assert.That(flashcards, Is.Empty); }