Skip to content

Commit

Permalink
Add unit test project.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Oct 13, 2017
1 parent db7c78d commit e25a577
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AsyncEnumerableExtensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncEnumerableExtensions", "AsyncEnumerableExtensions\AsyncEnumerableExtensions.csproj", "{F1E0806C-E78D-48E9-8C61-EAE3CB18B6F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{F783E085-5C68-405B-826B-6E24D362A67A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{F1E0806C-E78D-48E9-8C61-EAE3CB18B6F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1E0806C-E78D-48E9-8C61-EAE3CB18B6F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1E0806C-E78D-48E9-8C61-EAE3CB18B6F2}.Release|Any CPU.Build.0 = Release|Any CPU
{F783E085-5C68-405B-826B-6E24D362A67A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F783E085-5C68-405B-826B-6E24D362A67A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F783E085-5C68-405B-826B-6E24D362A67A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F783E085-5C68-405B-826B-6E24D362A67A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
29 changes: 29 additions & 0 deletions UnitTestProject1/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using AsyncEnumerableExtensions;
using Xunit;

namespace UnitTestProject1
{
public class UnitTest1
{
[Fact]
public async void Test1()
{
async Task Generator(IAsyncEnumerableSink<int> sink)
{
await sink.Yield(10);
await sink.Yield(20);
await Task.Delay(100);
await sink.Yield(30);
await sink.Yield(40);
await Task.Delay(100);
await sink.Yield(50);
}

Assert.Equal(new[] {10, 20, 30, 40, 50},
await AsyncEnumerableFactory.FromAsyncGenerator<int>(Generator).ToArray());
}
}
}
19 changes: 19 additions & 0 deletions UnitTestProject1/UnitTestProject1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AsyncEnumerableExtensions\AsyncEnumerableExtensions.csproj" />
</ItemGroup>

</Project>

0 comments on commit e25a577

Please sign in to comment.