Using TDD: “top down” vs. “bottom up”

后端 未结 7 1424
野趣味
野趣味 2021-01-31 18:57

Since I\'m a TDD newbie, I\'m currently developing a tiny C# console application in order to practice (because practice makes perfect, right?). I started by making a simple sket

7条回答
  •  深忆病人
    2021-01-31 19:15

    You can test your console application as well. I found it quite hard, look at this example:

    [TestMethod]
    public void ValidateConsoleOutput()
    {
        using (StringWriter sw = new StringWriter())
        {
            Console.SetOut(sw);
            ConsoleUser cu = new ConsoleUser();
            cu.DoWork();
            string expected = string.Format("Ploeh{0}", Environment.NewLine);
            Assert.AreEqual(expected, sw.ToString());
        }
    }
    

    You can look at the full post here.

提交回复
热议问题