The Research in Software Engineering team (RiSE) coordinates Microsoft's research in Software Engineering in Redmond, USA.
Very cool! One question: Does Moles work with other test frameworks (NUnit, MbUnit, ...) or just with the Visual Studio testing framework.
Also where can I buy one of those whiteboards It looks to be an EduBoard interactive whiteboard P3000, but they don't appear to have any retailers in the US.
Keep up the great work!
Moles work with any .NET executable, i.e. with any test framework that has a console application. We provide a better integration experience for Visual Studio Unit Test because it supports hosting. In the samples that ship with Pex/Moles, you will also find custom test framework extensions for NUnit, xUnit.net and MbUnit that allow a smooth integration. Don's hesitate to ask any questions on this on our forums.
It is not even a whiteboard, it is just a projector and a eBeam Whiteboard device
Nice! Now, if you could convince the C#/CLR guys to add this to the next release, so that the DLL generation was unnecessary...
In other words, I would like it if you could change the syntax of that added line of code to something like:
override get DateTime.Now = () => new DateTime(2000, 1, 1);
Very cool syntax indeed... but let's climb one mountain at a time
Am I the only one where this seem wrong by calling this testing when you modify the code by inserting
MDate.GetNow = () => New Date(2000,1,1)
Or am I missing something.
Idea add a attribute to the class,method etc, where within that scope the GET is intercepted and the test value is returned.
For Example:-
<Test.InterceptGet("System.Date.Now",() => new Date(2010,4,1))>
when we do testing we test a class at a time, so all external stuff is either stubbed or mocked so that you just test the functionality of the single class instead of doing system wide testing that are a nightmare to maintain. and if you test every single layer and it behaves as you expect while testing than everything should be good atleast from the code standpoint.
I can see alot of places where we can use this while doing ASP.NET at least.
By isolating your tests for environment dependencies, you make your tests deterministic, fast and easier to setup. This is very important for unit testing. This Isolated tests do not replace integration tests: you still have to run your code in end-to-end scenarios.
The attributes would not work for a number of reasons: you cannot declare delegates in attribute constructors. The string identifier is not verified by the compiler (in fact your example is wrong). Moles are strongly typed. In general, generics and all this good stuff would make it really hard to use any kind of attribute based solution.
The new version of Pex (0.22) ships with an example of Moles for Asp.NET (HttpContext, HttpRequest). Unzip the samples.zip that the installer produces and look under \Behaviors\System.Web.Behaviors.
That's why it was any Idea. Implementing is the idea down to smarter brains than mine.
Maybe I should have explained in more detail
The idea was when the code is run in "Test Mode" the Test Engine recognises that that class has a Test attribute.
So read the string part "System.Date,Now" which is interpted to mean that that method is called for by the CLR I want to use the alternative version.
The alternative version is provided via a func ( The Lamba Expression )
Shame about the attributes, having to be a constant expression, because its converted to metadata, I think having a func would be useful.
Imagine you have an AddressOf and point it a function contained in a test module.