Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

After reviewing the code further I have planned out how to break the form dependency in my code that I wish to test.

The code I wish to test IsLineValid currently depends on a function inside the same class called thisForm which returns a specific type of Access form that is in the system.

I am going to break the dependency by abstracting the retrieval of the form values to it’s own class. I am creating an interface called FormValueGetterI which has the public method ReadFormValue.

Then I am going to create two different classes implementing that interface.

One class will be for the Test code and be explicitly set up. I will be able to set the values I want the object to return rather than actually retrieve any form values.

The other class will be instantiated automatically in the LineController object when it is called (so I don’t have to add more code to specifically initialize it). This class will just collect the values from the thisForm object.

In this way the dependency is broken and I will be able to quickly run my tests I will create for the isValid function.

FormValueGetterI

Option Compare Database
Option Explicit

Public Function ReadFormValue(FieldName As String) As Variant: End Function

This as far as I got on the code so far today, so I’ll continue writing more tomorrow.