How do I test database-related code with NUnit?

后端 未结 5 1658
谎友^
谎友^ 2020-11-28 18:45

I want to write unit tests with NUnit that hit the database. I\'d like to have the database in a consistent state for each test. I thought transactions would allow me to \"u

5条回答
  •  清歌不尽
    2020-11-28 19:00

    I just went to a .NET user group and the presenter said he used SQLlite in test setup and teardown and used the in memory option. He had to fudge the connection a little and explicit destroy the connection, but it would give a clean DB every time.

    http://houseofbilz.com/archive/2008/11/14/update-for-the-activerecord-quotmockquot-framework.aspx

提交回复
热议问题