rama
rama

Reputation: 23

How to perform Nunit testing for a class inherting from a base class with parameterised constructor

namespace TestBI
{
 [TestFixture]
 class ClassChild:ClassParent
 {
    public ClassChild(DataRow row, string name): base(row, detail) { }
    [Test]
    public void Test()
    {
        DataRow dr = new DataRow();
        dr[0] = 1;
        dr[1] = "ram"  
        ClassChild ch = new ClassChild(dr,"student");

        :
        :
        :
        Assert.AreEqual(string1,string2);
     }

 }
}

When I run the test,i get an error as "TestBI.ChildClass.Test suitable constructor was found"

How do i need to pass parameters here to child class?

Upvotes: 1

Views: 884

Answers (1)

flup
flup

Reputation: 27103

Provide a zero argument constructor for your test class. It is fine if it calls a multiple argument constructor of the superclass, as long as it provides it with proper arguments.

Upvotes: 1

Related Questions