public void testPrintBannerSendsUnderline()
 {
     using (var writer = new StringWriter())
     {
         Console.SetOut(writer);
         UserInterface ui = new ConsoleUserInterface();
         ui.displayBanner("This is my banner!");
         Assert.IsTrue(writer.ToString().Contains("------------------"));
     }
 }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            List<User> users = JsonConvert.DeserializeObject<List<User>>(File.ReadAllText(USERS_FILE));
            List<Product> products = JsonConvert.DeserializeObject<List<Product>>(File.ReadAllText(PRODUCTS_FILE));

            UserInterface ui = new ConsoleUserInterface();

            Tusc.Start(users, products, ui);

            File.WriteAllText(USERS_FILE, JsonConvert.SerializeObject(users, Formatting.Indented));
            File.WriteAllText(PRODUCTS_FILE, JsonConvert.SerializeObject(products, Formatting.Indented));
        }
        public void testPromptUserToExitIncludesText()
        {
            using (var writer = new StringWriter())
            {
                Console.SetOut(writer);

                using (var reader = new StringReader(Environment.NewLine))
                {
                    Console.SetIn(reader);
                    UserInterface ui = new ConsoleUserInterface();
                    ui.promptUserToExit();
                    Assert.IsTrue(writer.ToString().Contains(Environment.NewLine + "Press Enter key to exit"));
                }
            }
        }
        public void testGetStringInputFromUserReturnsTheUserInput()
        {
            using (var writer = new StringWriter())
            {
                Console.SetOut(writer);

                using (var reader = new StringReader("Test" + Environment.NewLine))
                {
                    Console.SetIn(reader);
                    UserInterface ui = new ConsoleUserInterface();
                    string userInput = ui.getStringInputFromUser("This is my label: ");
                    Assert.AreEqual("Test", userInput);
                }
            }
        }
        public void testGetStringInputFromUserSendsLabelText()
        {
            using (var writer = new StringWriter())
            {
                Console.SetOut(writer);

                using (var reader = new StringReader("Test" + Environment.NewLine))
                {
                    Console.SetIn(reader);
                    UserInterface ui = new ConsoleUserInterface();
                    string userInput = ui.getStringInputFromUser("This is my label: ");
                    Assert.IsTrue(writer.ToString().Contains("This is my label: "));
                }
            }
        }
 public void testDisplayErrorIncludesText()
 {
     using (var writer = new StringWriter())
     {
         Console.SetOut(writer);
          UserInterface ui = new ConsoleUserInterface();
         ui.displayErrors("ERRORERROR");
         Assert.IsTrue(writer.ToString().Contains("ERRORERROR"));
     }
 }
 public void testDisplayNoticeIncludesText()
 {
     using (var writer = new StringWriter())
     {
         Console.SetOut(writer);
         UserInterface ui = new ConsoleUserInterface();
         ui.displayNotices("NOTICENOTICE");
         Assert.IsTrue(writer.ToString().Contains("NOTICENOTICE"));
     }
 }
 public void testDisplayWarningIncludesText()
 {
     using (var writer = new StringWriter())
     {
         Console.SetOut(writer);
         UserInterface ui = new ConsoleUserInterface();
         ui.displayWarnings("WARNINGWARNING");
         Assert.IsTrue(writer.ToString().Contains("WARNINGWARNING"));
     }
 }