Snippets created by Neil Danson

  • Undoable Commands

    A simple implementation of an Undoable Command, with a Document to hold a stack of actions. 2 examples of UndoableCommand are given - 1 allows property changes to be remembered, and another which allows the user to execute an action with a corresponding undo. Further examples could include CompositeUndoableCommands where the command is itself a list of commands.

    0 people like this

    Posted: 5 years ago by Neil Danson

  • BDD without a framework

    A Simple port of the Calculator BDD sample from http://cukes.info. Most BDD frameworks require attributes and shared state to run a test (I'm looking at you specflow!) As the test suite grows, the accidental complexity of different steps initialising (or not) class state becomes a huge problem, resulting in fragile tests. By accumulating state until the assertion, the tests become strongly typed and resilient to change. F#'s backtick methods combined with continuations and lightweight syntax can be taken to extremes to produce a lightweight internal DSL, with efficient results.

    10 people like this

    Posted: 2 years ago by Neil Danson