Let's create the a extremely simple test case. The first step is to setup db4ounit. The best way is to use db4ounit directly from the source. db4ounit is in the db4o source code folder of the distribution.
Open the db4o source-code of the db4o test-projects in Visual Studio. The db4ounit projects are called 'Db4oUnit' and 'Db4oUnit.Extensions'. Then create a new project which references the db4ounit projects.
After that we're ready to write our first db4ounit test. Create a new class which inherits from AbstractDb4oTestCase. Then add a test-method. Any method which starts with the prefix 'test' is a test method. Then add a main method which starts the test.
public class ExampleTestCase : AbstractDb4oTestCase { public static void Main(string[] args) { new ExampleTestCase().RunSolo(); } public void TestStoresElement() { Db().Store(new TestItem()); IList<TestItem> result = Db().Query<TestItem>(); Assert.AreEqual(1, result.Count); } private class TestItem { } }
Public Class ExampleTestCase Inherits AbstractDb4oTestCase Public Shared Sub Main(ByVal args As String()) Dim testCase = New ExampleTestCase() testCase.RunSolo() End Sub Public Sub TestStoresElement() Db().Store(New TestItem()) Dim result As IList(Of TestItem) = Db().Query(Of TestItem)() Assert.AreEqual(1, result.Count) End Sub Private Class TestItem End Class End Class