I’m just finished with the green phase meaning all my tests pass. That means I can refactor. I do have some redundant code in my tests, so i think I will refactor them to make them a little more readable. Here are my tests now:
I think just a very simple refactoring to extract the random TestText changes to a function. I did this and find my brain now spinning it’s wheels. I think there is more I could do, but I want to move on to a test. So here’s my current refactoring:
Putting on my red hat (for the create a failing test phase), I will now consider actually tracking a change with my FormAuditor. I know I will want to receive a list of the changes and be able to see what changes were made to which field. I currently only have one field on my form, so we will just use that for now.
At this point I’m interested in digging deeper into the returned collection to get the field name, the old value, the new value, and the date/time of the change.
Each Before Update event is triggering a new collection right now. Ooh, I just thought of an edge case though for our current system. If someone has not actually changed the value, I don’t want to receive that as a change (same old value and new value with just a timestamp).
Given: the Form Auditor control
When: a field is saved but the value is not changed
Then: an empty list of changes is returned
Let’s put that into a test (and I’ll update my ChangeTestText function with an optional new value to accomodate):
Victory! I have a failing test:

Now, to make it pass tomorrow.