forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOfTypeTests.cs
More file actions
40 lines (34 loc) · 1.05 KB
/
OfTypeTests.cs
File metadata and controls
40 lines (34 loc) · 1.05 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 Xunit;
namespace System.Linq.Tests
{
public class OfTypeTests : EnumerableBasedTests
{
[Fact]
public void EmptySource()
{
object[] source = { };
Assert.Empty(source.AsQueryable().OfType<int>());
}
[Fact]
public void HeterogenousSourceOnlyFirstOfType()
{
object[] source = { 10, "Hello", 3.5, "Test" };
int[] expected = { 10 };
Assert.Equal(expected, source.AsQueryable().OfType<int>());
}
[Fact]
public void NullSource()
{
Assert.Throws<ArgumentNullException>("source", () => ((IQueryable<object>)null).OfType<string>());
}
[Fact]
public void OfType()
{
var count = (new object[] { 0, (long)1, 2 }).AsQueryable().OfType<int>().Count();
Assert.Equal(2, count);
}
}
}