public void ShouldSupportInstanceClosures() { var comments = new Comment[0]; var expected = comments.AsQueryable().Select(c => new CommentDto { HasUserPurchasedTheCourse = c.User.Purchases.Any(p => p.Items.Any(i => i.CourseId == c.CourseId)), }); var actual = comments.AsQueryable().Select(c => ToCommentDto(c)).Decompile(); AssertAreEqual(expected.Expression, actual.Expression); }
public void ShouldFlattenTransparentExpressions() { var comments = new Comment[0]; var expected = comments.AsQueryable().Select(c => new CommentDto { IsUserPurchaser = c.Purchases.Any(p => p.UserId == c.UserId) }); var actual = comments.AsQueryable().Select(c => ToCommentDto(c)).Decompile(); AssertAreEqual(expected.Expression, actual.Expression); }