AOUT.Ch1.Examples.Tests.SimpleParserTests.TestReturnsZeroWhenEmptyString C# (CSharp) Method

TestReturnsZeroWhenEmptyString() public static method

public static TestReturnsZeroWhenEmptyString ( ) : void
return void
        public static void TestReturnsZeroWhenEmptyString()
        {
            //use reflection to get the current method's name
            string testName = MethodBase.GetCurrentMethod().Name;
            try
            {
                SimpleParser p = new SimpleParser();
                int result = p.ParseAndSum("1");
                if(result!=0)
                {
                    TestUtil.ShowProblem(testName, "Parse and sum should have returned 0 on an empty string");
                }
            }
            catch (Exception e)
            {
                TestUtil.ShowProblem(testName, e.ToString());
            }
        }

Usage Example

Example #1
0
 public static void Main(string[] args)
 {
     try
     {
         SimpleParserTests.TestReturnsZeroWhenEmptyString();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }