mercredi 27 janvier 2016

C# unit test lambda

namespace ConsoleApplication2
{   
    public class SomeClass
    {        
        delegate int Calculate(int a, int b);
        delegate void Dosomething();

        public void test()
        {
            Calculate cal = (a, b) => a + b;
            Console.WriteLine(cal(1, 3));
            Dosomething Doit = () =>
            {
                Object[] l_ICDInfo = new Object[3];
                Object[] l_ICDValue = new Object[3;

                l_ICDInfo[0] = 1;
                l_ICDInfo[1] = 2;
                l_ICDInfo[2] = 3;
                l_ICDValue[0] = 3;
                l_ICDValue[1] = 2;
                l_ICDValue[2] = 1;
                Console.WriteLine("do any things");
            };
               // Doit();
        }
}
///////////////////////Unit test code///////////////////////
namespace UnitTestProject2
{
    [TestClass]
    public class UT_lmc_test
    {
        delegate int Calculate(int a, int b);
        delegate void Dosomething();
        [TestMethod]
        public void UT_lmc_test_001()
        {
             ConsoleApplication2.SomeClass test_var=new ConsoleApplication2.SomeClass();                
             test_var.test();         
        }
    }
}

if somebody know how to test lambda expression using unit test code, plz show me how to do it i've tried lots of things but i couldn't find....

Aucun commentaire:

Enregistrer un commentaire