Hi i m just got into the nunit world and i m facing the following problem .
i have an abstract class like
and i want some other classes to inherit the above likeCode:[TestFixture] public abstract class ConnectionFixture { private OleDbConnection connection; [TestFixtureSetUp] public void OpenConnection() { this.connection=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ConfigurationSettings.AppSettings.Get("databasePath")); this.connection.Open(); } [TestFixtureTearDown] public void CloseConnection() { this.connection.Close(); } public OleDbConnection Connection { get {return this.connection;} } }
but using that design the openConnection method is never executed. How can i make it to execute only once?Code:[TestFixture] public class UserFixture:ConnectionFixture { private User insertedUser; [TestFixtureSetUp] public void SetUp() { insertedUser=new User(Connection); insertedUser.Name="testUser"; insertedUser.ReceiptCountInterval=1; insertedUser.ReceiptTimeIntervalStart=DateTime.Now; insertedUser.ReceiptTimeIntervalStop=DateTime.Now; insertedUser.Save(); Assert.IsTrue(insertedUser.ID>0); }




Reply With Quote