1

Closed

set containing nulls and a call to"ShouldContainInOrder" throws NRE

description

gents,

because I'm an idiot, and I thought this would be a small task, I wrote my own quasi-CSV serializer. Now I'm testing it, and I've found an NRE in your nice framework:

I've got an IEnumerable<object> that looks like the following:
{{ {1, 2, 3, 4, "a string", 5, [null], 6, "another string"} }}
I'm doing
{{ thatIEnumerable.Should().ContainInOrder(anotherEnumerableThatsIdentical); }}
and I'm getting
Null Reference Exception
at FluentAssertions.Assertions.CollectionAssertions2.<>c__DisplayClass5.<ContainInOrder>b__4(Object a) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\CollectionAssertions.cs:line 673
at System.Linq.Enumerable.<SkipWhileIterator>d__52
1.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at FluentAssertions.Assertions.CollectionAssertions
2.ContainInOrder(IEnumerable expected, String reason, Object[] reasonArgs) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\CollectionAssertions.cs:line 673
at FluentAssertions.Assertions.CollectionAssertions`2.ContainInOrder(IEnumerable expected) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\CollectionAssertions.cs:line 637
at IQ.ProductLibrary.InitialPopulation.Tests.ProductCsvTranslatorFixture.when_reading_a_product_in_a_language_that_does_not_contain_all_entries_in_the_desired_language() in C:\Code\ProductLibrary\Clean\tests\InitialPopulation.Tests\ProductCsvTranslatorFixture.cs:line 132

--keep in mind that because that null is expected, a
{{
 foreach(var expectedElement in anotherIEnumerableThatsIdentical)
 {
      ... expectedElement.Equals(actualElement)
}}
will throw that NRE.
Closed Aug 25, 2012 at 2:19 PM by
All done with the public beta of Fluent Assertions 2.0

comments

Groostav wrote Jun 26, 2012 at 11:32 PM

so what does
{{ markup only work in the comments }}

wrote Jun 27, 2012 at 7:58 PM

Resolved with changeset 79638: Fixed some possible null reference exceptions