forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAllTests.cs
More file actions
40 lines (34 loc) · 1.09 KB
/
AllTests.cs
File metadata and controls
40 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Linq.Expressions;
using Xunit;
namespace System.Linq.Tests
{
public class AllTests : EnumerableBasedTests
{
[Fact]
public void PredicateTrueAllExceptLast()
{
int[] source = { 4, 2, 10, 12, 8, 6, 3 };
Assert.False(source.AsQueryable().All(i => i % 2 == 0));
}
[Fact]
public void NullSource()
{
Assert.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).All(i => i != 0));
}
[Fact]
public void NullPredicateUsed()
{
Expression<Func<int, bool>> predicate = null;
Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).AsQueryable().All(predicate));
}
[Fact]
public void All()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().All(n => n > 1);
Assert.False(val);
}
}
}