Fixed in v3.3 trunk. Merged in v3.2 branch. Will be included in v3.2.3 release.
2011/2/11 Yann Trevin <[email protected]> > It looks like you have found a glitch. > > It should be relatively easy to fix. I think it's only a matter of > modifying StructuralEqualityComparer<T> so it handles correctly with null > references (nothing). > > But I don't believe I will have time to do it before the release of next > week. Or does someone want to make the fix happen or to submit a patch? So > it will make v3.2.3... > > I made an issue <http://code.google.com/p/mb-unit/issues/detail?id=814>for > that. > > 2011/2/11 Molivier <[email protected]> > > Hi, >> >> I'm testing StructuralEqualityComparer (wich is a great idea) in >> vb.net 3.5 and mbunit 3.2.0.0. >> >> AreElementsEqual works fine with collection containing null values, >> exemple : >> -------------------------------------------------------------------- >> <Test()> _ >> Public Sub dummy() >> >> Dim actual As New List(Of Date)(New Date() {Nothing, >> #2/2/2002#}) >> Dim expected As New List(Of Date)(New Date() {Nothing, >> #2/2/2002#}) >> >> Assert.AreElementsEqual(expected, actual) >> >> End Sub >> -------------------------------------------------------------------- >> >> >> >> But when using AreElementsEqual with StructuralEqualityComparer and >> when a collection item is null, System.NullReferenceException is >> raised, exemple : >> -------------------------------------------------------------------- >> Public Class Dateclass >> >> Public dateutc As Date >> >> Public Sub New(ByVal pDateUtc As Date) >> Me.dateutc = pDateUtc >> End Sub >> End Class >> >> >> ''' <summary>Lambda expression are better in C#</summary> >> Public Shared ReadOnly Property DateclassEqualityComparer() As >> StructuralEqualityComparer(Of Dateclass) >> Get >> Dim ec As New StructuralEqualityComparer(Of >> Dateclass) >> ec.Add(Function(item As Dateclass) item.dateutc) >> Return ec >> End Get >> End Property >> >> >> <Test()> _ >> Public Sub dummyOk() >> >> Dim actual As New List(Of Dateclass)(New Dateclass() {New >> Dateclass(#2/2/2002#)}) >> Dim expected As New List(Of Dateclass)(New Dateclass() {New >> Dateclass(#2/2/2002#)}) >> >> Assert.AreElementsEqual(expected, actual, >> Exemple.DateclassEqualityComparer) >> >> End Sub >> >> <Test()> _ >> Public Sub dummyFail() >> >> Dim actual As New List(Of Dateclass)(New Dateclass() >> {Nothing, New >> Dateclass(#2/2/2002#)}) >> Dim expected As New List(Of Dateclass)(New Dateclass() >> {Nothing, New >> Dateclass(#2/2/2002#)}) >> >> Assert.AreElementsEqual(expected, actual, >> Exemple.DateclassEqualityComparer) >> >> End Sub >> -------------------------------------------------------------------- >> >> "dummyFail" throw System.NullReferenceException : is it a bug ? Is >> there a workaround ? >> >> Thanks ! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "MbUnit.User" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/mbunituser?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "MbUnit.User" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/mbunituser?hl=en.
