Skip to content

Commit

Permalink
Regression test for #5085
Browse files Browse the repository at this point in the history
  • Loading branch information
smitpatel committed Nov 13, 2019
1 parent 400d9d8 commit 65fb930
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/EFCore.Specification.Tests/MusicStoreTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,30 @@ await context.Database.CreateExecutionStrategy().ExecuteAsync(
});
}

[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public virtual async Task Custom_projection_FirstOrDefault_works(bool async)
{
using var context = CreateContext();
var shoppingCartId = "CartId_A";
var id = 1;
var query = context.CartItems
.Select(ci => new CartItem
{
CartId = ci.CartId,
CartItemId = ci.CartItemId,
Count = ci.Count,
Album = new Album { Title = ci.Album.Title }
});

var cartItem = async
? await query.FirstOrDefaultAsync(ci => ci.CartId == shoppingCartId && ci.CartItemId == id)
: query.FirstOrDefault(ci => ci.CartId == shoppingCartId && ci.CartItemId == id);

Assert.Null(cartItem);
}

private static CartItem[] CreateTestCartItems(string cartId, decimal itemPrice, int numberOfItems)
{
var albums = CreateTestAlbums(
Expand Down

0 comments on commit 65fb930

Please sign in to comment.