Skip to content

Commit

Permalink
Add tests for #2420, issue no longer reproduces.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikary committed Oct 12, 2015
1 parent dc30d95 commit bdf1aa3
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,54 @@ public override void From_sql_queryable_stored_procedure_min()
Sql);
}

public override void From_sql_queryable_with_multiple_stored_procedures()
{
base.From_sql_queryable_with_multiple_stored_procedures();

Assert.StartsWith(
@"[dbo].[Ten Most Expensive Products]
[dbo].[Ten Most Expensive Products]
[dbo].[Ten Most Expensive Products]",
Sql);
}

public override void From_sql_queryable_stored_procedure_and_select()
{
base.From_sql_queryable_stored_procedure_and_select();

Assert.StartsWith(
@"[dbo].[Ten Most Expensive Products]
SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitsInStock]
FROM (
SELECT * FROM Products
) AS [p]
SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitsInStock]
FROM (
SELECT * FROM Products
) AS [p]",
Sql);
}

public override void From_sql_queryable_select_and_stored_procedure()
{
base.From_sql_queryable_select_and_stored_procedure();

Assert.StartsWith(
@"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitsInStock]
FROM (
SELECT * FROM Products
) AS [p]
[dbo].[Ten Most Expensive Products]
[dbo].[Ten Most Expensive Products]",
Sql);
}

public FromSqlSprocQuerySqlServerTest(NorthwindSprocQuerySqlServerFixture fixture)
: base(fixture)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,55 @@ public virtual void From_sql_queryable_stored_procedure_with_include_throws()
}
}

[Fact]
public virtual void From_sql_queryable_with_multiple_stored_procedures()
{
using (var context = CreateContext())
{
var actual
= (from a in context.Set<MostExpensiveProduct>().FromSql(TenMostExpensiveProductsSproc)
from b in context.Set<MostExpensiveProduct>().FromSql(TenMostExpensiveProductsSproc)
where a.TenMostExpensiveProducts == b.TenMostExpensiveProducts
select new { a, b })
.ToArray();

Assert.Equal(10, actual.Length);
}
}

[Fact]
public virtual void From_sql_queryable_stored_procedure_and_select()
{
using (var context = CreateContext())
{
var actual
= (from mep in context.Set<MostExpensiveProduct>().FromSql(TenMostExpensiveProductsSproc)
from p in context.Set<Product>().FromSql("SELECT * FROM Products")
where mep.TenMostExpensiveProducts == p.ProductName
select new { mep, p })
.ToArray();

Assert.Equal(10, actual.Length);
}
}

[Fact]
public virtual void From_sql_queryable_select_and_stored_procedure()
{
using (var context = CreateContext())
{
var actual
= (from p in context.Set<Product>().FromSql("SELECT * FROM Products")
from mep in context.Set<MostExpensiveProduct>().FromSql(TenMostExpensiveProductsSproc)
where mep.TenMostExpensiveProducts == p.ProductName
select new { mep, p })
.ToArray();

Assert.Equal(10, actual.Length);
}
}


protected NorthwindContext CreateContext()
{
return Fixture.CreateContext();
Expand Down

0 comments on commit bdf1aa3

Please sign in to comment.