Re: Key word suggestions?
Hans Christian Falkenberg <[email protected]> Mon, 8 Sep 2008 22:37:52 +0200 (CEST)
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 8 Sep 2008, Charlie Poole wrote: > Hi Olof, > > Some folks didn't like "Using" but assuming it takes > an IComparer as an argument and that comparers are > usually named SomeSortOfComparer, what about just > plain... > > Assert.That( data, Is.EqualTo(expected).Using(myComparer); > > Of course "Using" is fairly generic, but any future > overloads could be distinguished by their argument. > > I'm pretty sure there's no confusion with C# using. Except in poor syntax highlighters. Which I'm sure there are at least a couple of (think code posted on the web). FxCop warns against this (CA1716) http://msdn.microsoft.com/en-us/library/ms182248(VS.80).aspx Indeed if you look at the MS documentation shipped with Visual Studio for System.Random.Next(), the Visual Basic code example incorrectly highlights the method as a keyword. My vote is on UsingComparer because it avoids keywords clashes and makes it perfectly clear what it is you are using from a glance. + Hans Christian > Charlie > >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On >> Behalf Of Olof Bjarnason >> Sent: Monday, September 08, 2008 12:08 PM >> To: Charlie Poole >> Cc: [email protected] >> Subject: Re: [nunit-developer] Key word suggestions? >> >> 2008/9/8 Charlie Poole <[email protected]>: >>> Hi Olof, >>> >>> A good idea... here are two sets using different constraints >>> >>> Assert.That( data, Is.EqualTo(expected).Comparer(myComparer); >>> Assert.That( data, Is.EqualTo(expected).CompareWith(myComparer); >>> Assert.That( data, Is.EqualTo(expected).Using(myComparer); >>> Assert.That( data, Is.EqualTo(expected).UseComparer(myComparer); >> >> Just playing a little: >> >> Assert.That( data, Is.EqualTo(expected).UseComparer(myComparer); >> Assert.That( data, Is.EqualTo(expected).UsingComparer(myComparer); >> Assert.That( data, Is.EqualTo(expected).WhereEqualMeans(myComparer); >> >> >>> etc. >>> >>> and >>> >>> Assert.That(myCollection, Is.OrderedBy("Key").Comparer(myComparer); >>> Assert.That(myCollection, >>> Is.OrderedBy("Key").CompareWith(myComparer); >>> Assert.That(myCollection, Is.OrderedBy("Key").Using(myComparer); >>> Assert.That(myCollection, >>> Is.OrderedBy("Key").UseComparer(myComparer); >> >> Assert.That(myCollection, >> Is.OrderedBy("Key").UsingComparer(myComparer); >> >> Reading it aloud: >> >> 'Assert that myCollection is ordered by "Key" using comparer >> myComparer' >> >> If forced to choose one for both scenarios my choice would be >> "UsingComparer", even though it is not on your original list :) >> >> >>> etc. >>> >>> Currently those are the only two places where this modifier >> is used, >>> but I see making more use of it in future. My working assumption is >>> that it will generally be easier for users if we use the >> same word in >>> all cases, even though they are technically independent. >>> >>> Charlie >>> >>> >>>> -----Original Message----- >>>> From: Olof Bjarnason [mailto:[email protected]] >>>> Sent: Monday, September 08, 2008 10:51 AM >>>> To: Charlie Poole >>>> Cc: [email protected] >>>> Subject: Re: [nunit-developer] Key word suggestions? >>>> >>>> Charlie could we get a complete line of sourcecode to make >> a better >>>> judgement..? >>>> >>>> 2008/9/6 Charlie Poole <[email protected]>: >>>>> Hi All, >>>>> >>>>> EqualConstraint takes a modifier "Comparer(IComparer >>>> comparer)", which >>>>> causes the specified IComparer to be used when testing >> for equality. >>>>> >>>>> This same feature is being added in other constraints, like >>>>> OrderedCollectionConstraint. >>>>> >>>>> Before we get too many of them, I want to ask if "Comparer" >>>>> is the best way to express this. Other options that come to mind >>>>> are >>>>> >>>>> CompareWith(IComparer) >>>>> CompareUsing(IComparer) >>>>> UseComparer(IComparer) >>>>> Using(IComparer) >>>>> ... >>>>> >>>>> It's a smallish issue, but I thought I'd ask. >>>>> >>>>> Charlie >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >> --------------------------------------------------------------------- >>>> - >>>>> --- 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-developer mailing list >>>>> [email protected] >>>>> https://lists.sourceforge.net/lists/listinfo/nunit-developer >>>>> >>>> >>> >>> >>> >>> >> >> -------------------------------------------------------------- >> ----------- >> 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-developer mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/nunit-developer >> > > > > ------------------------------------------------------------------------- > 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-developer mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/nunit-developer > ------------------------------------------------------------------------- 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=/