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
(1)
222 times
Add to favorites
12/24/2015
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
using System;

namespace TDD_Katas_project.StringSum
{
    public class StringSumKata
    {
        public static string Sum(string num1, string num2)
        {
            var realNum1 = GetZeroWhenNullOrEmpty(num1);
            var realNum2 = GetZeroWhenNullOrEmpty(num2);

            return Convert.ToString(Add(realNum1, realNum2));
        }

        private static string GetZeroWhenNullOrEmpty(string num1)
        {
            return string.IsNullOrEmpty(num1) ? "0" : num1;
        }

        private static int Add(string realNum1, string realNum2)
        {
            return int.Parse(realNum1) + int.Parse(realNum2);
        }

    }
}