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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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);
}
}
}