You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0 KiB
C#

6 years ago
using System;
6 years ago
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using FluentAssertions;
6 years ago
namespace LinqStudy.Test.LinqToObject
{
/// <summary>
/// 生成操作符
/// </summary>
public class CreateTest
{
6 years ago
/// <summary>
/// Empty 返回指定类型的空集,没有任何元素的集合。
/// Enumerable的静态方法常用来做初始种子集合。
/// </summary>
/// <remarks>
/// Enumerable
/// </remarks>
[Fact]
public void Empty_string_Test()
{
var ini= Enumerable.Empty<string>();
Assert.IsType<string[]>(ini);
Assert.Empty(ini);
}
/// <summary>
/// 注意返回值为Enumerable<T>,而不是List<T>
/// </summary>
[Fact]
public void Empty_Class_Test()
{
var ini = Enumerable.Empty<Person>();
Assert.IsType<Person[]>(ini);
Assert.Empty(ini);
}
6 years ago
}
}