StringCheckApplication with Unit test

Create and exe with below informaiton :


namespace StringCheckApplication
{
    public class CombineString
    {
 
        public string combineArrayStringWithSpace(string[] stringArray)
        {
            string str = default(string);
 
            foreach (string item in stringArray)
            {
                str += item + " ";
            }
 
            return str.Trim();
        }
    }
}

namespace StringCheckApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            CombineString objCS = new CombineString();
        }
 
    }
}

=================================================
Now create TestApplicaiton:
Refer exe in unittest applicaiton 

namespace StringCheckApplication.Tests
{
    [TestClass()]
    public class CombineStringTests
    {
        [TestMethod()]
        public void combineArrayStringWithSpaceTest()
        {
            CombineString target = new CombineString(); // TODO: Initialize to an appropriate value
            string[] stringArray = null// TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;
            actual = target.combineArrayStringWithSpace(stringArray);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }  
 
        [TestMethod()]
        public void PossitiveSchenarioForChecking_combineArrayStringWithSpace()
        {
            string expectedResult = "Today is the wonderful day of my life";
            string[] actualStringArray = new string[] { "Today""is""the""wonderful""day""of""my""life" };
            CombineString appObject = new CombineString();
            string actualResult = appObject.combineArrayStringWithSpace(actualStringArray);
            Assert.AreEqual<string>(expectedResult, actualResult);
        }
    }
}

Comments

Popular posts from this blog

25ThApril 2020