[NOTE (For Joe Only): Joe, yes, this is a "shiny stuff" post; some day it might have a practical use at which point I’ll write a non-alpha geek version of this post which will be a tutorial of how to use this to make your life easier.]
1:// NOTE: what follows is something I could do not something that is fully working
2:// the JS Style Attributes work and that is all
12: [Observation("When adding a person, full name should not be blank")]
15: Script.Literal("/*--@Concern("When adding a person, full name should not be blank")--*/");
16:// Test Code appears here
See that Script.Literal in the constructor? That’s required for my JS Attributes Library and for Script#. You see we have to force a comment into Script#, and do it in a manner that the comment ends up in the runtime version (non-debug version) of the code.
One of the things I’ve been thinking about is how something like Script# DLLs lend themselves for testing. Seriously. If you take an UI behavior approach to components, then you need to isolate the functionality by creating a fake element (or more than one), attach the behavior and then start firing events on the model to make sure that the desired results happen. For instance if I have a draggable element then I want to make sure that the element shows the hand cursor when the mouse passes over the element as well as when the mouse button is down and the mouse is moved does the element’s position changes, etc. I keep thinking that this should be infinitely easier in the DLL as an abstraction then in the actual browser. Of course one needs to test various browsers, but if your math is off for instance, it won’t matter which browser you use.
Why BDD and not TDD? Well, I usually have a list of rules that the UI Behavior should adhere to before I ever write a line of code. This is a perfect fit for a BDD style of test first (and yes, I want to do BDD testing first... I know that’s shocking, but I do want to try it... for how I TRY to build JS components quality is usually a huge factor that BDD would greatly help).