1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Generate TestCases for Methods based on its Signature using CodeDom in C#

Discussion in 'C#' started by pragadheesh, Mar 24, 2009.

  1. pragadheesh

    pragadheesh New Member

    Joined:
    Mar 24, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Consider the following Code snippet,

    Code:
    Assembly asm = Assembly.LoadFile(DLL_Path);
    Type t = asm.GetType(DLL_NameSpace.MyClass, false, true);
    clsMethodInvoke mi = new clsMethodInvoke();
    foreach (MemberInfo oMember in t.GetMembers(mi.GetFilter()))
    {
                                    //code here
    }
    These are the values in the follwing variables,

    Code:
    t = {Name = "Class1" FullName = "a.Class1"}
    oMember = {Int32 add(Int32, Int32)}
    Now from these values i need to Generate NUnit based TestCases as follows,

    Code:
    [Test()]
    public virtual void Testadd1() {
        Class1 Class1 = new Class1();
    
        int a = -1; //random values are stored here
        int b = 2147483647; //random values are stored here
    
    }
    So having the type of the Class in an Assembly i want to generate test cases for each method, as show above. How can i generate such Test Cases.?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    It would be that your DLL Name would be something that you would change and not the loading of the file which you need to test.

    DLL_Path
     

Share This Page