Todo.txt TDD Part 3

As mentioned at the end of Part 2, after the creation date, the rest of the string is called the Description. It can contain projects that start with a plus sign(+) or contexts that start with an at symbol(@) or key/value pairs with a colon(:). We’ll test the projects piece now.

I’m testing zero, one, and two projects. Now let’s update Raw to make this pass

This loops through the rest of the elements of the split array and looks for a plus sign at the start. If it finds one, it creates a Project instance and adds it to the Projects collection class. The contexts will be handled similarly.

The final special case inside the description is key/value pairs.

Again I’m testing zero, one, and two instances.

Everything else is the description

Here are the changes to the bottom of Raw

And that’s it. A properly parsed Todo.txt string ready to be used in your application. And if I make an changes to my app, I can run these tests to make sure I didn’t break anything.

You can download TodoTxt.zip

Series:
Series:

  1. todo-txt-tdd-part-1/
  2. todo-txt-tdd-part-2/
  3. todo-txt-tdd-part-3/

2 thoughts on “Todo.txt TDD Part 3

  1. The file doesn’t work.
    The error mesage is….
    —-
    Public Sub Initialize()

    Set gclsTodos = New CTodos
    gclsTodos.FillFromFile <—– (Yellow)
    —-

    How do I fix it?
    Thank you

  2. The error is happening inside the class. It’s almost certainly because you don’t have a file named todo.txt in the same folder as the TodoTxt.xlsm workbook. The text file can be empty, but it must be there and be named properly.

    To see the real error, in the VBE go to Tools – Options – General and choose Break in Class Module in the Error Trapping area. The offending line inside the class module will be highlighted. If it’s not the file opening, post back and let me know.


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.