1
0
Эх сурвалжийг харах

Moving Queryable tests to their own projects.

Bart De Smet 8 жил өмнө
parent
commit
8316c1e12f

+ 19 - 0
Ix.NET/Source/Ix.NET.sln

@@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Tests", "
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable.Tests", "System.Linq.Async.Queryable.Tests\System.Linq.Async.Queryable.Tests.csproj", "{134E9066-6217-4AF0-B408-47D92AB595BD}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Test\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -277,6 +279,22 @@ Global
 		{134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x64.Build.0 = Release|Any CPU
 		{134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.ActiveCfg = Release|Any CPU
 		{134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.Build.0 = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|ARM.ActiveCfg = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|ARM.Build.0 = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x64.Build.0 = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x86.Build.0 = Debug|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|ARM.ActiveCfg = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|ARM.Build.0 = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.ActiveCfg = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.Build.0 = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.ActiveCfg = Release|Any CPU
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -295,6 +313,7 @@ Global
 		{792093F9-83E4-4630-9652-4328FDAED15F} = {61683064-A120-44A7-A174-E19154F6D84F}
 		{2E23D7AD-0B21-4725-87C4-BD43271260A1} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}
 		{134E9066-6217-4AF0-B408-47D92AB595BD} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}
+		{974056C0-91BD-4EB6-8431-E30A614FD1D4} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7}

+ 45 - 0
Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs

@@ -0,0 +1,45 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using Xunit;
+using System;
+
+namespace Tests
+{
+    internal class AssertEx
+    {
+        internal static void Throws<T>(Action action, Func<T, bool> assert)
+            where T : Exception
+        {
+            var failed = false;
+
+            try
+            {
+                action();
+            }
+            catch (T ex)
+            {
+                Assert.True(assert(ex));
+
+                failed = true;
+            }
+
+            Assert.True(failed);
+        }
+
+        internal static void SucceedOrFailProper(Action action)
+        {
+            try
+            {
+                action();
+            }
+            catch (AggregateException ex)
+            {
+                var inner = ex.Flatten().InnerException;
+
+                // TODO: proper assert; unfortunately there's not always a good call stack
+            }
+        }
+    }
+}

+ 17 - 17
Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs → Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs

@@ -394,6 +394,16 @@ namespace Tests
 
         [Fact]
         public void MaxBy1()
+        {
+            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(int)), ane => ane.ParamName == "source");
+            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, int>>)), ane => ane.ParamName == "keySelector");
+
+            var res = AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int));
+            AssertEx.SucceedOrFailProper(() => res.Wait());
+        }
+
+        [Fact]
+        public void MaxBy2()
         {
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(Task<int>)), ane => ane.ParamName == "source");
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, Task<int>>>)), ane => ane.ParamName == "keySelector");
@@ -403,17 +413,17 @@ namespace Tests
         }
 
         [Fact]
-        public void MaxBy2()
+        public void MaxBy3()
         {
-            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(int)), ane => ane.ParamName == "source");
-            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, int>>)), ane => ane.ParamName == "keySelector");
+            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source");
+            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, int>>), CancellationToken.None), ane => ane.ParamName == "keySelector");
 
-            var res = AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int));
+            var res = AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None);
             AssertEx.SucceedOrFailProper(() => res.Wait());
         }
 
         [Fact]
-        public void MaxBy3()
+        public void MaxBy4()
         {
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(int), Comparer<int>.Default), ane => ane.ParamName == "source");
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, int>>), Comparer<int>.Default), ane => ane.ParamName == "keySelector");
@@ -424,7 +434,7 @@ namespace Tests
         }
 
         [Fact]
-        public void MaxBy4()
+        public void MaxBy5()
         {
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(Task<int>), CancellationToken.None), ane => ane.ParamName == "source");
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, Task<int>>>), CancellationToken.None), ane => ane.ParamName == "keySelector");
@@ -434,7 +444,7 @@ namespace Tests
         }
 
         [Fact]
-        public void MaxBy5()
+        public void MaxBy6()
         {
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(Task<int>), Comparer<int>.Default), ane => ane.ParamName == "source");
             AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, Task<int>>>), Comparer<int>.Default), ane => ane.ParamName == "keySelector");
@@ -444,16 +454,6 @@ namespace Tests
             AssertEx.SucceedOrFailProper(() => res.Wait());
         }
 
-        [Fact]
-        public void MaxBy6()
-        {
-            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(default(IAsyncQueryable<int>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source");
-            AssertEx.Throws<ArgumentNullException>(() => AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression<Func<int, int>>), CancellationToken.None), ane => ane.ParamName == "keySelector");
-
-            var res = AsyncQueryableEx.MaxBy<int, int>(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None);
-            AssertEx.SucceedOrFailProper(() => res.Wait());
-        }
-
         [Fact]
         public void MaxBy7()
         {

+ 0 - 0
Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt → Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt


+ 0 - 0
Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs → Ix.NET/Source/System.Interactive.Async.Providers.Test/NopObserver.cs


+ 50 - 0
Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj

@@ -0,0 +1,50 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
+    <NoWarn>$(NoWarn);CS0618</NoWarn>
+  </PropertyGroup>
+
+
+  <ItemGroup>
+    <Content Include="xunit.runner.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" />
+    <ProjectReference Include="..\System.Interactive\System.Interactive.csproj" />
+    <ProjectReference Include="..\System.Linq.Async\System.Linq.Async.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
+    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta4-build3742 " />
+    <PackageReference Include="FluentAssertions" Version="4.19.2 " />
+
+    <PackageReference Include="xunit" Version="2.3.0-beta3-build3705" />
+    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742 " />
+
+  </ItemGroup>
+
+  <ItemGroup>
+    <None Update="AsyncQueryableExTests.Generated.tt">
+      <LastGenOutput>AsyncQueryableExTests.Generated.cs</LastGenOutput>
+      <Generator>TextTemplatingFileGenerator</Generator>
+    </None>
+  </ItemGroup>
+
+  <ItemGroup>
+    <Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Compile Update="AsyncQueryableExTests.Generated.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>AsyncQueryableExTests.Generated.tt</DependentUpon>
+    </Compile>
+  </ItemGroup>
+
+</Project>

+ 5 - 0
Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json

@@ -0,0 +1,5 @@
+{
+  "diagnosticMessages": true,
+  "methodDisplay": "classAndMethod",
+  "longRunningTestSeconds": 30 
+}

+ 45 - 0
Ix.NET/Source/System.Linq.Async.Queryable.Tests/AssertEx.cs

@@ -0,0 +1,45 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using Xunit;
+using System;
+
+namespace Tests
+{
+    internal class AssertEx
+    {
+        internal static void Throws<T>(Action action, Func<T, bool> assert)
+            where T : Exception
+        {
+            var failed = false;
+
+            try
+            {
+                action();
+            }
+            catch (T ex)
+            {
+                Assert.True(assert(ex));
+
+                failed = true;
+            }
+
+            Assert.True(failed);
+        }
+
+        internal static void SucceedOrFailProper(Action action)
+        {
+            try
+            {
+                action();
+            }
+            catch (AggregateException ex)
+            {
+                var inner = ex.Flatten().InnerException;
+
+                // TODO: proper assert; unfortunately there's not always a good call stack
+            }
+        }
+    }
+}

+ 0 - 0
Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs → Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncEnumerableQueryTest.cs


+ 0 - 0
Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs → Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs


+ 0 - 0
Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt → Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt


+ 19 - 0
Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj

@@ -27,4 +27,23 @@
 
   </ItemGroup>
 
+  <ItemGroup>
+    <None Update="AsyncQueryableTests.Generated.tt">
+      <LastGenOutput>AsyncQueryableTests.Generated.cs</LastGenOutput>
+      <Generator>TextTemplatingFileGenerator</Generator>
+    </None>
+  </ItemGroup>
+
+  <ItemGroup>
+    <Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Compile Update="AsyncQueryableTests.Generated.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>AsyncQueryableTests.Generated.tt</DependentUpon>
+    </Compile>
+  </ItemGroup>
+
 </Project>