Tuesday, July 13, 2004

I have added abunch of classes for database testing  in the TestFu project (Download Now ):

 

·         SqlAdministrator: backup, restore, create or drop  databases, and also some methods on tables, constraints,etc...

·         SqlExplorer: extracts the schema of database to a DataSet

·         SqlFixture: a mini data abstraction layer "TestFixture" oriented

 

Let's see them in action...

 

SqlAdministrator

 

·         Backup  database to a file:

·         Restore a database from a file:

·         Drop a database:

·         Drop a table:

·         Drop a constraint:

·         etc...

 

using System;
using TestFu.Data;

public class Demo
{
    public static void Main(string[] args)
    {
        DbAdministrator admin = new SqlAdministrator("...");    
        
        // backup Northwind
        admin.Backup("Northwind",SqlBackupDevice.Disk,@"c:\Backups\Northwind.bkp");
        
        // drop Northwind
        admin.Drop("Northwind");
        
        // restore Northwind
        admin.Restore("Northwind",SqlBackupDevice.Disk,@"c:\Backups\Northwind.bkp");
    }
}

SqlFixture

The DbFixture (SqlFixture for MsSQL server) can be used as a base class for the fixtures involving database testing:

[TestFixture]
public class DatabaseTest : SqlFixture
{
    public DatabaseTest()
    :base("Data Source=testserver;...","MyTestDatabase")
    {}
    
    [SetUp]
    public void SetUp()
    {
        this.Open();
        this.BeginTransaction();
    }
    
    [Test]
    public void Selec()
    {
        IDbCollection cmd = this.Connection.CreateCommand("select * from anytable",this.Transaction);
        ...
    }
    
    [TearDown]
    public void TearDown()
    {
        this.Close();
    }
}
posted on Wednesday, July 14, 2004 3:34:00 AM UTC  #    Comments [3]
Tracked by:
"metal security door" (online) [Trackback]
"wine accessory rack" (online) [Trackback]
"sterling silver tray" (online) [Trackback]
Monday, June 06, 2005 5:51:01 PM UTC
Unable to download TestFu 0.2 project. Link gives me error: An error has occurred writing to the exception log. The permissions are not set properly on the log file or directory, or the log file has been marked as READ-ONLY.
Eric
Monday, June 06, 2005 5:51:02 PM UTC
TestFu is distributed with <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a>, which is distributed with <a title="TestDriven.NET" href="http://www.testdriven.net" target="_blank">TestDriven.NET</a>, which can be downloaded at www.testdriven.net ;)
Jonathan de Halleux
Monday, June 06, 2005 5:51:04 PM UTC
Wow, superb!
<br>Thanks.
Diana
Comments are closed.