Home
Testing
Frog.NET has pretty good built-in support for unit testing - well some would argue that its really an integration test once your using a database. Anyway, the strategy I have used for testing is to create a database connection to an in-memory SQLite database. When the test finishes, I just discard the connection and everything is back to normal, ready for the next test to run.This approach has very low execution time, and closely mimics how the real database will work. Since Frog.NET code is database independent, you can also choose to run your test suite against a real database like SQL Server.
A typical example:
1: [Test]
2: public void RemoveAll()
3: {
4: using (var connection = new SqliteConnection("Data Source=:memory:;version=3");)
5: {
6: var repository = new Repository(connection);
7: CreateThreeCustomers(repository);
8:
9: repository.RemoveAll<Customer>();
10: Assert.That(repository.GetAll<Customer>().Count(), Is.EqualTo(0));
11: }
12: }
