Re: Writing custom constraints
"Charlie Poole" <[email protected]> Thu, 21 Aug 2008 18:24:09 -0700
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <001801c903f5$c962dc60$6401a8c0@ferrari> |
Hi Brad, > The threading on this message will probably be messed up. I > apparently missed your reply, and it's not in my inbox > anywhere. Hopefully, the list will adjust and thread it > properly, but if not, I at least used the same subject. > > > See http://nunit.org/index.php?p=customConstraints&r=2.4.8 > > > It's very basic but intellisense and experimentation should > give you > > the rest. > > I surmised as much, based on examining the source for a > couple of constraints, including the abstract base. I think > "elegant" describes it. Much simpler than I thought it would be. Great! I'm glad it works for you. > > Note that this allows writing a custom constraint only. You > could use > > it like Assert.That(x, new MyCustomConstraint()); > > Yes, that's all that's really needed right now. I'm > investigating whether or not it's worth it to write custom > constraints for some of our custom structs. I'm also toying > with the idea of a constraint that reflects over the members > of simple structs, i.e. ones with all primitive values, to > compare. We use a fair number of structs, which we use as > return values from various web services, and it'll save some > time to write one constraint, instead of one for each. > Haven't actually > *tried* it, but it *sounds* like it might work. :) Yes, provided you could deal with invalid args in some way. That could be as simple as an argument exception. > > 1. If you work exclusively in C# 3.0 use extension methods. > > Thought of that too, but not all of our projects are C# 3.0. > 'Course, that doesn't really matter if I just say "in order > to use this, at least your unit test project must be C# 3.0," > since it's our general practice to put the tests in a > separate project in the same solution. MSBuild seems to > handle it OK. Might be a good excuse to upgrade existing > ones when they need it, too. :) That shoud work. > > For 2.5, I'm working to make the syntax layer extensible > just like the > > constraints. > > I'm using the current 2.5 Alpha for this effort, in case > there's something in there I might be able to use... Nothing yet, but soon. Right now I'm exercising all the parameterized test stuff by converting my constraint tests to use it. I'll consolidate that work and then take a look at the syntax layer again. Charlie > Brad > > > -------------------------------------------------------------- > ----------- > 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 > ------------------------------------------------------------------------- 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=/