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.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
|
|
|
|
|
namespace LinqStudy.Test.LinqToObject
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成操作符
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CreateTest
|
|
|
|
|
{
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|