I am experimenting with a .NET testing framework along the lines of rspec and would like to implement a custom editor in Visual Studio for this purpose.
For the uninitiated, rspec is a testing framework for ruby and tests (or specs) look like this:
describe Bowling, "#score" do
it "returns 0 for all gutter game" do
bowling = Bowling.new
bowling.hit(0)
bowling.score.should eq(0)
end
end
In ruby, it is possible to write rspec tests as a block nested anonymous functions without any enclosing method or class - this is dealt with by the framework behind the scenes at runtime.
I would like to do something along these lines in Visual Studio 2012 and/or 2013. A complete C# test file might look something like this:
using System;
using BowlingApp;
using Specs;
@spec DefaultSpec
Describe(typeof(Bowling), "#score", () => {
It("returns 0 for all gutter game", () => {
var bowling = new Bowling();
bowling.Hit(0);
Expect(bowling.Score).ToEqual(0);
});
});
... where the @spec
statement specifies the base class for the "enclosing" type that wil be generated behind the scenes (at design time, in this case). The base class would also supply the Describe
, It
and Expect
methods used in the example above.
In order to make this testing framework practical to use, I would need a custom VS editor for the format above with syntax highlighting and intellisense.
Is it possible to "repurpose" the existing C# editor in VS to do this or would I have to do everything from scratch? If so, are there any open source tools or frameworks that might help me create such an editor?