Riddle me this:
Given I have a class 'calculator.js' written in JavaScript
I would like to unit-test each method in this class - prefereably using C# - prefereably using dynamic invocation of the methods in the class
so, ideally:
[TEstMethod]
public void Divide_WhenDividendIsZero_ResultIsZero()
{
// Arrange
dynamic myJsClass = someFactory.CreateInstanceOf(myJsFilePath);
// Act
var result = (int) myJsClass.Divide(9, 0);
// Assert
result.ShouldEqual(0, "Division by zero should result in zero");
}
According to the hype, .Net 4.0 introduces the possibility to do this, however, I have not found any good tutorials on what I need to rig this up.
For the majority of my tests, WebDriver will do, however, for the "pure" javascript classes, this is my preferred way to do it - if it is possible at all?