Skip to main content

Hands on Test Driven Development Katas

In these days, Test Driven Development (TDD) is one of the most growing things in the technical world. Most of us are following Agile methodology where we would like to test our code within code.In this article, we will discuss all about TDD Katas and how we can get hands-on with

C# (10.0 MB)
5 Star
223 times
Add to favorites
E-mail Twitter Digg Facebook

Solution explorer

using NUnit.Framework;

namespace TDD_Katas_project.OddEvenKata
    [Category("OddEven Kata")]
    public class TestOddEven
        [TestCase(1, 50)]
        [TestCase(1, 100)]
        [TestCase(5, 150)]
        public void CanPrintOddEven(int startRange, int endRange)
            var result = OddEven.PrintOddEven(startRange, endRange);
            Assert.NotNull(result, string.Format("{0}", result));

        [TestCase(1, "Odd")]
        [TestCase(3, "3")]
        [TestCase(5, "5")]
        [TestCase(4, "Even")]
        [TestCase(9, "Odd")]
        [TestCase(10, "Even")]
        public void CanPrintOddEvenForSingleNumber(int number, string expectedresult)
            var actualresult = OddEven.PrintSingleOddEven(number);
            Assert.That(expectedresult, Is.EqualTo(actualresult),
                        string.Format("result of entered number [{0}] is [{1}] but it should be [{2}]", number,
                                      actualresult, expectedresult));