Hey!
Like I said already, it's awesome :-)
Small comments inline ;-)
On Mar 9, 8:02 pm, Exception <
dan.abra...@gmail.com> wrote:
> Good evening to you all guys.
> Now that I had some free time, I've adopted my code to the framework
> changes Sebastien had done, and it looks very hot :-)
>
> The first file <
groups.google.com/group/gendarme/web/
> Test.Rules.tar.bz2> contains a MonoDevelop project (I'm not a console
> guy) with classes to be referenced from any Test.Rules.* project that
> wants to make use of them (actually, all new unit tests should use
> these helpers). These classes allow us to concentrate on *what* we
> want to check in our unit tests, not *how* this is really being done.
> If you are feeling uncertain, have a look at the example code
> <
groups.google.com/group/gendarme/web/Gendarme.Rules.Design.tar.bz2>.
> These are some of existing unit tests rewritten with the help of
> Test.Rules classes, and you can see that the code has become clearer,
> better and easier to read and maintain. Hooray!
About Perfect[Method|Type]...
* I don't really like the name (and yes I think *I* suggested it ;-)
What about Default ? Common ? Basic ? or Shared ? was one of them the
original name I rejected !?!? (if so then I blame my cold ;-) or has
anyone anything better in mind ?
* Instead of an enum they could be a static type, with a bunch of
static properties returning [Method|Type]Definition. This would remove
the need for all Perfect[Methods|Types] overloads while keeping the
nice syntax.
* Remove AssertRuleFailure(Perfect[Methods|Types]...) overloads. First
because *Perfect*[Methods|Types] should never fail ;-) and also
because [Method|Type]Definition overloads (existing or to be added)
makes them unneeded.
* Move them into a new/different namespace, e.g.
Test.Rules.Definitions
Other stuff
* I don't think "return type.FullName.Replace ('+', '/');" is needed
for TypeDefinition since it's already in the "right" format.
> As of now, not everything on the list is implemented. I'm gonna code a
> helper for the assembly rules in the near future and also introduce
> several more complex overloads for AssertRuleFailure allowing
> specification of expected severity and/or confidence (this is a very
> easy kind of work yet extremely boring given that there are no default
> values for parameters in C#). I would deeply appreciate any help with
> it.
I don't think we need more overloads. Since the runner has all the
defects stored (inside itself) we can issue specific assert calls to
check them (but any call to AssertRule* should clear them). This would
makes it possible to share the methods between Assembly, Type and
Method test types.
E.g. AssertDefect (int n, Severity s, Confidence c);
so if you expect a failure with 2 defects you need to
AssertRuleFailure (method, 2);
AssertDefect (0, Severity.High, Confidence.Normal);
AssertDefect (1, Severity.High, Confidence.Normal);
or maybe we could also add, because it happens for a lot of rule,
AssertAllDefects (Severity.High, Confidence.Normal);
That should cover more than 80% of the cases. If some stuff needs to
check further details then it should directly access the Runner.Defect
property and use the basic Assert on the values.
> Any ideas and suggestions are, as always, welcome!
I still have not (yet) tried/compiled/executed them. I'll sleep on
them (and let my subconscious work a bit more on it) and do that
tomorrow.
Great work!
Sebastien