Stephen Boissiere
2008-06-09 16:19:04 UTC
Hi, I have a proposal for a possible improvement to nunit's usage. I
could implement this if there was a demand for it, but wanted to know a)
is it already there and b) is it worth it?
Basically if you have heard of LLBLGen Pro I was 'inspired' by an idea
from their code. It is a good ORM and I recommend it. Anyway, the point
is they allow you to build a query using operator overloads e.g.
table.Fill ( MyTable.MyField == 23 );
this would fill a table with all rows where MyField == 23. This is done
by overloading operator == to return an object instead of a bool. The
new object describes the comparison.
For nunit I propose an optional syntax like:
Assert.That(Is.Value(2 + 2) == 4);
'Value' is a proposed new static method. It would return a new class
(e.g. ValueWrapper) with overloaded operator == which returns an
'EqualConstraint'. Something like:
class ValueWrapper
{
...
public static EqualConstraint operator == ( ValueWrapper lhs, object
rhs )
{
return new EqualConstraint ( lhs.InnerValue, rhs );
}
...
}
So - am I too late, or is it just not that good an idea?
Thanks,
Stephen Boissiere
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
could implement this if there was a demand for it, but wanted to know a)
is it already there and b) is it worth it?
Basically if you have heard of LLBLGen Pro I was 'inspired' by an idea
from their code. It is a good ORM and I recommend it. Anyway, the point
is they allow you to build a query using operator overloads e.g.
table.Fill ( MyTable.MyField == 23 );
this would fill a table with all rows where MyField == 23. This is done
by overloading operator == to return an object instead of a bool. The
new object describes the comparison.
For nunit I propose an optional syntax like:
Assert.That(Is.Value(2 + 2) == 4);
'Value' is a proposed new static method. It would return a new class
(e.g. ValueWrapper) with overloaded operator == which returns an
'EqualConstraint'. Something like:
class ValueWrapper
{
...
public static EqualConstraint operator == ( ValueWrapper lhs, object
rhs )
{
return new EqualConstraint ( lhs.InnerValue, rhs );
}
...
}
So - am I too late, or is it just not that good an idea?
Thanks,
Stephen Boissiere
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php