public void FirstOrDefaultEmpty() { Assert.Equal(0, ImmutableArrayExtensions.FirstOrDefault(empty)); Assert.Equal(0, ImmutableArrayExtensions.FirstOrDefault(empty, n => true)); Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.FirstOrDefault(empty, null)); Assert.Equal(0, ImmutableArrayExtensions.FirstOrDefault(emptyBuilder)); }
public void FirstOrDefault() { Assert.Equal(Enumerable.FirstOrDefault(oneElement), ImmutableArrayExtensions.FirstOrDefault(oneElement)); Assert.Equal(Enumerable.FirstOrDefault(manyElements), ImmutableArrayExtensions.FirstOrDefault(manyElements)); foreach (bool result in new[] { true, false }) { Assert.Equal(Enumerable.FirstOrDefault(oneElement, i => result), ImmutableArrayExtensions.FirstOrDefault(oneElement, i => result)); Assert.Equal(Enumerable.FirstOrDefault(manyElements, i => result), ImmutableArrayExtensions.FirstOrDefault(manyElements, i => result)); } Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.FirstOrDefault(oneElement, null)); Assert.Equal(Enumerable.FirstOrDefault(oneElementBuilder), ImmutableArrayExtensions.FirstOrDefault(oneElementBuilder)); Assert.Equal(Enumerable.FirstOrDefault(manyElementsBuilder), ImmutableArrayExtensions.FirstOrDefault(manyElementsBuilder)); }
public void FirstOrDefaultEmptyDefault() { Assert.Throws <NullReferenceException>(() => ImmutableArrayExtensions.FirstOrDefault(emptyDefault)); Assert.Throws <NullReferenceException>(() => ImmutableArrayExtensions.FirstOrDefault(emptyDefault, n => true)); Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.FirstOrDefault(emptyDefault, null)); }
public void FirstOrDefault() { Assert.Equal(Enumerable.FirstOrDefault(oneElement), ImmutableArrayExtensions.FirstOrDefault(oneElement)); Assert.Equal(Enumerable.FirstOrDefault(manyElements), ImmutableArrayExtensions.FirstOrDefault(manyElements)); Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.FirstOrDefault(oneElement, null)); }