Categories

    Tags

Database tests with automated verifications of modifications

Home Forums General Database tests with automated verifications of modifications

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Admin Admin 10 years, 1 month ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2072
    Profile photo of Admin
    Admin
    Keymaster

    Can anyone recommend a good framework (preferably open source) for .NET that can be used for database testing ?

    I know that [url=http://www.ndbunit.org/:w70nzqow]NDbUnit[/url:w70nzqow] can be used for putting a database into a known state, but the thing I want to be able to do is the following:
    (1) Define the expected database changes that I want my following code to trigger
    (2) Take a snapshow of the database before my test code starts
    (3) Execute my code being tested
    (4) Verify that all the changes have been done to the database

    In other words, I am looking for a component that can be used in a similar way as some mock object frameworks where you record the expected methods that should be invoked by your code, but instead I want to record the expected database changes that will be triggered by my code.

    To further explain what I mean, here is a code sample of the kind of feature I would wish:

    string connectionString = …
    DbTest dbTest = new DbTest(connectionString);
    dbTest.AddExpectation(new RowsInserted("tableName1", 3)); // 3 rows are expected to become inserted to table "tableName1"
    dbTest.AddExpectation(new RowsDeleted("tableName2", 4)); // 4 rows are expected to become deleted from table "tableName2"
    dbTest.AddExpectation(new UpdatedRow("tableName3", "columnName1", "newValue", "123"));
    // the value of the column "columnName1" will get the value "newValue" at the row with the primarykey "123" in the table "tableName3"

    dbTest.MakeSnapShotOfTheDatabase(); // the content of the database will be stored internally in the DbTest class

    // the code that should cause the above changes to the database (for example NHibernate code or whatever)

    dbTest.VerifyAllExpectationsHaveBeenMetSinceTheSnapshot();

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

New User?

Register
Do NOT follow this link or you will be banned from the site!