Re: StreamsEqual issue(s)
"Charlie Poole" <[email protected]> Wed, 13 Aug 2008 09:59:08 -0700
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <002001c8fd65$ec52c230$6401a8c0@ferrari> |
Hi Gert, Hey! I'm glad someone is looking at that. :-) Are you looking to test Mono itself with 2.4.8 or just ship with it? I'm not real familiar with that constraint, but your points make sense. I'll look it over. More inline... > I was having a quick look at the impact of upgrading the > version of NUnit in Mono from 2.2 to 2.4.8, and noticed some > test regressions. > > I had a closer look at one of these regressions, and the > reason it failed is because EqualConstraint.StreamsEqual > expects both streams to be readable and seekable. If not, > this results in an exception. So your test was previously comparing two streams with Assert.AreEqual? Since NUnit had no prior code for streams, you would be getting Stream.Equals (i.e. Object.Equals). The easiest fix would be to use Assert.SameAs if that's what you want. > I don't think an assert should result in an exception (other > than AssertionException.cs). Agreed... plus any ArgumentInvalid, etc. that are the fault of the user. > I also noticed NUnit is changing the position in the stream > (to the start of the stream), and doesn't change it back > afterwards. Should an Assert by itself be allowed to change > the state of a stream? In some cases, NUnit actually creates the stream by opening a file. But in others, it may be passed in as an argument. Theoretically, we should not change it or at least document that it may be changed. I'll look at it. > I'm also not sure if NUnit should actually read these > streams. What will you do if the stream is readable and not > seekable? You'd change the position in the stream (by > positioning at the beginning and by reading it), and you > can't change it back to the origin position. I can't think of any good use case for wanting to assert on the equality of two non-seekable streams. Can you? Maybe I should just throw an InvalidArgumentException. > Apart from this, I wondered why NUnit is not always checking > for reference equality first? Why bothering checking the > content of two streams, it they are actually the same? But why is the user bothering to use the Assert in that case? He should be using AreSame rather than AreEqual. OTOH, I can imagine odd cases where it would not be possible to know in advance, so it's worth a check. I wasn't planning to do any more development in the 2.4 code line, but I guess I could do a fix for mono if there turn out to be any issues that require it. Alternatively, you may want to look at 2.5, which will get active maintenance after it is released. Charlie > Gert > > > -------------------------------------------------------------- > ----------- > 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=/