-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test project for F# functional tests. (#34541)
- Added the project EFCore.FSharp.FunctionalTests - Created a fixture for the Northwind database - Implemented a sample test analogous to the Visual Basic tests Fixes #14572
- Loading branch information
Showing
5 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/EFCore.FSharp.FunctionalTests/EFCore.FSharp.FunctionalTests.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<AssemblyName>Microsoft.EntityFrameworkCore.FSharp.FunctionalTests</AssemblyName> | ||
<SkipTests Condition="'$(OS)' != 'Windows_NT' AND '$(Test__SqlServer__DefaultConnection)' == ''">True</SkipTests> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EFCore.SqlServer.FunctionalTests\EFCore.SqlServer.FunctionalTests.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="NorthwindFSharpQuerySqlServerFixture.fs" /> | ||
<Compile Include="NorthwindQueryFSharpTest.fs" /> | ||
</ItemGroup> | ||
|
||
</Project> |
14 changes: 14 additions & 0 deletions
14
test/EFCore.FSharp.FunctionalTests/NorthwindFSharpQuerySqlServerFixture.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.FSharp.FunctionalTests | ||
|
||
open Microsoft.EntityFrameworkCore.Infrastructure | ||
open Microsoft.EntityFrameworkCore.Query | ||
|
||
type NorthwindFSharpQuerySqlServerFixture<'TModelCustomizer | ||
when 'TModelCustomizer : (new: unit -> 'TModelCustomizer) | ||
and 'TModelCustomizer :> ITestModelCustomizer>() = | ||
inherit NorthwindQuerySqlServerFixture<'TModelCustomizer>() | ||
|
||
override self.StoreName = "NorthwindFSharp" |
38 changes: 38 additions & 0 deletions
38
test/EFCore.FSharp.FunctionalTests/NorthwindQueryFSharpTest.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.FSharp.FunctionalTests | ||
|
||
open System.Linq | ||
open Microsoft.EntityFrameworkCore.Query | ||
open Microsoft.EntityFrameworkCore.TestModels.Northwind | ||
open Microsoft.EntityFrameworkCore.TestUtilities | ||
open global.Xunit | ||
|
||
type NorthwindQueryFSharpTest(fixture) as self = | ||
inherit QueryTestBase<NorthwindFSharpQuerySqlServerFixture<NoopModelCustomizer>>(fixture) | ||
|
||
do fixture.TestSqlLoggerFactory.Clear() | ||
|
||
let assertSql (sql: string) = | ||
fixture.TestSqlLoggerFactory.AssertBaseline([|sql|]) | ||
|
||
[<ConditionalTheory>] | ||
[<MemberData(nameof NorthwindQueryFSharpTest.IsAsyncData)>] | ||
let ListLiteral_Contains (isAsync: bool) = | ||
task { | ||
do! self.AssertQuery(isAsync, (fun ss -> ss.Set<Customer>().Where(fun c -> ["ALFKI"; "ALFKI2"].Contains(c.CustomerID)))) | ||
assertSql( | ||
"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] | ||
FROM [Customers] AS [c] | ||
WHERE [c].[CustomerID] IN (N'ALFKI', N'ALFKI2')") | ||
} | ||
|
||
member private self.RewriteExpectedQueryExpressionRedirect expression = base.RewriteExpectedQueryExpression expression | ||
member private self.RewriteServerQueryExpressionRedirect expression = base.RewriteServerQueryExpression expression | ||
|
||
override self.CreateQueryAsserter fixture = | ||
new RelationalQueryAsserter( | ||
fixture, | ||
(fun e -> self.RewriteExpectedQueryExpressionRedirect(e)), | ||
(fun e -> self.RewriteServerQueryExpressionRedirect(e))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters