generator and tests

This commit is contained in:
neuecc
2020-05-08 12:08:15 +09:00
parent 856a049dd0
commit ed0990e402
13 changed files with 1763 additions and 2586 deletions

View File

@@ -0,0 +1,65 @@
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace UniTask.NetCoreTests.Linq
{
public class Factory
{
[Theory]
[InlineData(0, 10)]
[InlineData(0, 0)]
[InlineData(1, 5)]
[InlineData(1, 0)]
[InlineData(0, 11)]
[InlineData(1, 11)]
public async Task RangeTest(int start, int count)
{
var xs = await UniTaskAsyncEnumerable.Range(start, count).ToArrayAsync();
var ys = Enumerable.Range(start, count).ToArray();
xs.Should().BeEquivalentTo(ys);
}
[Theory]
[InlineData("foo", 0)]
[InlineData("bar", 1)]
[InlineData("baz", 3)]
[InlineData("foobar", 10)]
[InlineData("foobarbaz", 11)]
public async Task RepeatTest(string value, int count)
{
var xs = await UniTaskAsyncEnumerable.Repeat(value, count).ToArrayAsync();
var ys = Enumerable.Repeat(value, count).ToArray();
xs.Should().BeEquivalentTo(ys);
}
[Fact]
public async Task EmptyTest()
{
var xs = await UniTaskAsyncEnumerable.Empty<int>().ToArrayAsync();
var ys = Enumerable.Empty<int>().ToArray();
xs.Should().BeEquivalentTo(ys);
}
[Theory]
[InlineData(100)]
[InlineData((string)null)]
[InlineData("foo")]
public async Task ReturnTest<T>(T value)
{
var xs = await UniTaskAsyncEnumerable.Return(value).ToArrayAsync();
xs.Length.Should().Be(1);
xs[0].Should().Be(value);
}
}
}

View File

@@ -9,10 +9,17 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UniTask.NetCore\UniTask.NetCore.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using Xunit;
namespace UniTask.NetCoreTests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}