> Assert.That( () => objectUnderTest.DoSomething,
> Throws<InvalidOperationException>().Message.EqualTo("My Test Message");
Is this something in future or I missed. I don't see a Throws<T>
class. Or may be you meant
Assert.That(() => { throw new InvalidOperationException("aaa"); },
Throws.InvalidOperationException.With.Message.EqualTo("aaa"));
Yes, that reads very nicely. Maybe I was lazy and I should really
spend sometime digest all the properties of With and nested With and
so on. I feel it is not intuitive of when and what is applicable.
Cheers,
Kenneth
> http://alexgorbatchev.com/wiki/SyntaxHighlighter
Thanks for the info. I had been at
http://developertips.blogspot.com/2007/08/syntaxhighlighter-on-blogger.html.
Looks very nice but it still requires me to manually insert <pre> and
replace < with <. Not that I cannot deal with HTML and CSS, I guess
I'm too lazy or I want everything just quick.
I need copy, past and publish type of thing that looks OK, not
necessary perfect so Mark's fit me better.
That being said, I do appreciate your help and thanks again.
Cheers,
Kenneth
> Assert.That( () => someObject.SomeMethod()
> Raises...
This syntax looks nice for simply asserts. But become hard and verbose
when I need to assert various things.
In the case of ArgumentException, I usually assert message and
ParamName so I find myself use Assert.Throws and Assert.Catch more
often.
In order to work with event of any delegate type. The return value
should contains all the parameters of a delegate. In Mark's example,
what if I also need to assert the sender?
I believe linq/anonymous class will be useful here.
Cheers,
Kenneth
> Throws.ArgumentException.Message.EqualTo("xxxx")
> .Property("ParamName").EqualTo("yyyy")
Interesting! As I said I need to spend sometime to this. But still, I
don't really see it is better then Assert.Catch approach. The biggest
issue with Throws constraint is that I lost direct access to exception
object so it becomes difficult for complex evaluation of the
exception. And yes the string name of property is reminding me the
time I migrate off NMock2.
Cheers,
Kenneth