-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #135
- Loading branch information
Showing
4 changed files
with
156 additions
and
41 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
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,95 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace DelegateDecompiler.Tests | ||
{ | ||
[TestFixture] | ||
public class Issue135 : DecompilerTestsBase | ||
{ | ||
public class Post { | ||
public bool IsActive { get; set; } | ||
} | ||
|
||
public class Blog | ||
{ | ||
public bool HasBar { get; } | ||
public bool HasBaz { get; } | ||
|
||
public IEnumerable<Post> Posts { get; } | ||
|
||
|
||
[Decompile] | ||
public bool HasFoo | ||
{ | ||
get { return (HasBar || HasBaz) && Posts.Any(x => x.IsActive); } | ||
} | ||
|
||
[Decompile] | ||
public bool HasFoo2 | ||
{ | ||
get { return (HasBar && Posts.Any(x => x.IsActive)) || (HasBaz && Posts.Any(x => x.IsActive)); } | ||
} | ||
|
||
[Decompile] | ||
public bool HasFoo3 | ||
{ | ||
get { return Posts.Any(x => x.IsActive) && (HasBar || HasBaz); } | ||
} | ||
} | ||
|
||
[Test, Ignore("Not fixed")] | ||
public void Test1() | ||
{ | ||
var blogs = new[] {new Blog()}.AsQueryable(); | ||
|
||
var expected = ( | ||
from b in blogs | ||
where (b.HasBar || b.HasBaz) && b.Posts.Any(x => x.IsActive) | ||
select b); | ||
|
||
var actual = ( | ||
from b in blogs | ||
where b.HasFoo | ||
select b).Decompile(); | ||
|
||
AssertAreEqual(expected.Expression, actual.Expression); | ||
} | ||
|
||
[Test, Ignore("Not fixed")] | ||
public void Test2() | ||
{ | ||
var blogs = new[] {new Blog()}.AsQueryable(); | ||
|
||
var expected = ( | ||
from b in blogs | ||
where (b.HasBar && b.Posts.Any(x => x.IsActive)) || (b.HasBaz && b.Posts.Any(x => x.IsActive)) | ||
select b); | ||
|
||
var actual = ( | ||
from b in blogs | ||
where b.HasFoo2 | ||
select b).Decompile(); | ||
|
||
AssertAreEqual(expected.Expression, actual.Expression); | ||
} | ||
|
||
[Test] | ||
public void Test3() | ||
{ | ||
var blogs = new[] {new Blog()}.AsQueryable(); | ||
|
||
var expected = ( | ||
from b in blogs | ||
where b.Posts.Any(x => x.IsActive) && (b.HasBar || b.HasBaz) | ||
select b); | ||
|
||
var actual = ( | ||
from b in blogs | ||
where b.HasFoo3 | ||
select b).Decompile(); | ||
|
||
AssertAreEqual(expected.Expression, actual.Expression); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.