Unit testing data operations with Access database in VB.NET

DescriptionThis code sample will provide a method to unit test backend database operations, adding records, updating records and removal of records using ms-access database table.I’ve been on various developer forums where developers have issues with their data operations and in

172 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Imports BackEnd
''' <summary>
''' We would only code the following after running the unit test ReadCustomers
''' where the assert return true.
''' After each successful test we can then code that functionality into the 
''' form code below then test here too. 
''' To keep things clean, place the database into the project folder 
''' but don't delete it as the unit tests are dependent on it being there then
''' in the property windows use Copy always for copy to output directory so 
''' after each test here we can inspect the database before another build is done
''' to ensure what worked in the unit test worked here also.
''' </summary>
Public Class Form1
    Private bsCustomers As New BindingSource()
    Private dataOps As New Operations()
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        bsCustomers.DataSource = dataOps.ReadCustomers()
        bindingNavigator1.BindingSource = bsCustomers
        dataGridView1.DataSource = bsCustomers
    End Sub
End Class