Creating Test 2 (2)

After make it sure it failed, now we add some code in controller to make it pass the test.

public class FizzBuzzController : Controller
{
    // GET: FizzBuzz
    public ActionResult Index(int value)
    {
        for (int i = 1; i <= value; i++)
        {
            if (i % 3 == 0)
                ViewBag.Output += "Fizz";
            else
                ViewBag.Output += i.ToString()+" ";
        }
        return View();
    }
}

Run the test again. After the test is passed, now is Refactoring. Refactoring means looking at the code if there are lines of code that can be deleted, to remove the ambiguity.

results matching ""

    No results matching ""