forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryable.cs
More file actions
68 lines (57 loc) · 1.8 KB
/
Queryable.cs
File metadata and controls
68 lines (57 loc) · 1.8 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace System.Linq.Tests
{
public class QueryableTests
{
[Fact]
public void AsQueryable()
{
Assert.NotNull(((IEnumerable)(new int[] { })).AsQueryable());
}
[Fact]
public void AsQueryableT()
{
Assert.NotNull((new int[] { }).AsQueryable());
}
[Fact]
public void NullAsQueryableT()
{
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).AsQueryable());
}
[Fact]
public void NullAsQueryable()
{
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable)null).AsQueryable());
}
private class NonGenericEnumerableSoWeDontNeedADependencyOnTheAssemblyWithNonGeneric : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield break;
}
}
[Fact]
public void NonGenericToQueryable()
{
Assert.Throws<ArgumentException>(() => new NonGenericEnumerableSoWeDontNeedADependencyOnTheAssemblyWithNonGeneric().AsQueryable());
}
[Fact]
public void ReturnsSelfIfPossible()
{
IEnumerable<int> query = Enumerable.Repeat(1, 2).AsQueryable();
Assert.Same(query, query.AsQueryable());
}
[Fact]
public void ReturnsSelfIfPossibleNonGeneric()
{
IEnumerable query = Enumerable.Repeat(1, 2).AsQueryable();
Assert.Same(query, query.AsQueryable());
}
}
}