Re: How to extend the constraint model with customconstraints
"Charlie Poole" <[email protected]> Thu, 7 Aug 2008 14:48:25 -0700
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <00b501c8f8d7$54c98850$6401a8c0@ferrari> |
I like the concept, but I've been unable to make it work without extension methods. So how did you do it? Charlie _____ From: [email protected] [mailto:[email protected]] On Behalf Of Simone Busoli Sent: Thursday, August 07, 2008 2:00 PM To: [email protected] Subject: Re: [Nunit-users] How to extend the constraint model with customconstraints I've TDDed it for some minutes and I found it's simpler than I thought. I can do this now: Assert.That(2 + 2).Iz.EqualTo(4); Assert.That(2 + 2).Iz.Not.EqualTo(5); Assert.That( list).Iz.EqualTo(new string[] { "foo", "bar" }); Assert.That(7).Iz.GreaterThan(3); Assert.That(7).Iz.Not.GreaterThan(8); Assert.That(7).Iz.GreaterThanOrEqualTo(7); I know this would be a breaking change Charlie, but don't you think this could be better than the constraint model? The advantages I see are: - discoverability: just type DOT after That and you see what you have available - fluency - extensibility Thoughts? On Thu, Aug 7, 2008 at 9:47 PM, Simone Busoli <[email protected]> wrote: What about, instead of this: Assert.That(value, Is.Not.EqualTo(other)); this one? Assert.That(value).Is.Not.EqualTo(other)); I don't know it if would ever work, but I like it more, and I think it could be extensible since Is/Has is no longer forced to be a static class. On Thu, Aug 7, 2008 at 9:39 PM, Simone Busoli <[email protected]> wrote: What's the best way of adding a new constraint so that I can use it, preferably before a patch is submitted, applied and a new version is released? I am thinking about extension methods, but the classes Is, Has... expose constraints with static methods. I can create my constraint manually in the second argument of Assert.That, but I would lose the fluency of the syntax. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Nunit-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nunit-users