locked
how to test constructor of class in nunit test ? RRS feed

  • Question

  • hi all

    i hav the C++ ref class dll file . in tat i hav constructor pls look at code sample

    public ref class

     

     Somestring{

     

    public:

    Somestring(); 
    Somestring(sInt64 somestring);

    property

     

    sInt64 somestring{

    sInt64 get()

    {

     

    return somestring;

    }

     

    void set(sInt64 value) {

    somestring= value;

    }

    }


    }


    i am giving this class reference in my C# tresting dll file ..

    bt whnever i creat object i can only get the acess to property not to constructor ..


    may i knw hw can i test constructor here ?

    thx in adavce ( is this forum is not correct place to post this ..pls let me knw anothr forum )

    Friday, November 27, 2009 7:05 AM

Answers

  • hi

    i got solution

    just check the oject is created or nt

    assert.IsnotNull(object); // object will only creat whn it ll call constructor hence its true
    • Marked as answer by aniruddha84 Monday, November 30, 2009 6:27 AM
    Monday, November 30, 2009 6:26 AM

All replies

  • hi

    i got solution

    just check the oject is created or nt

    assert.IsnotNull(object); // object will only creat whn it ll call constructor hence its true
    • Marked as answer by aniruddha84 Monday, November 30, 2009 6:27 AM
    Monday, November 30, 2009 6:26 AM
  • hi

     

    this all about the NUnit testing in C#.

    when u create the noject u call the constructor.

    ClassA obj = new ClassA();

    hence to test constructor in unit test test the object is created or not

     

    first create the object and then test that object is null or not

    assert.IsnotNul is the method provided by the NUnit tool.

    for any othr reference u can search on google :)

    regards,

     

    Aniruddha.

    Wednesday, September 22, 2010 4:21 AM
  • aniruddha84, Whitney is just a spammer whose goal is to add hidden link seo spam to forums.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, January 28, 2011 5:19 AM
  • thx , ll take care next time
    Friday, January 28, 2011 7:16 AM