forked from hazzik/DelegateDecompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Unit tests for issue hazzik#135
Force DecompilerTestBase to visit decompiled expressions
- Loading branch information
Max
committed
Jan 6, 2019
1 parent
5de630e
commit ee5422b
Showing
2 changed files
with
77 additions
and
3 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,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
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 (this.HasBar || this.HasBaz) && this.Posts.Any(x => x.IsActive); | ||
} | ||
} | ||
|
||
[Decompile] | ||
public bool HasFoo2 | ||
{ | ||
get | ||
{ | ||
return (this.HasBar && this.Posts.Any(x => x.IsActive)) || (this.HasBaz && this.Posts.Any(x => x.IsActive)) ; | ||
} | ||
} | ||
|
||
[Decompile] | ||
public bool HasFoo3 | ||
{ | ||
get | ||
{ | ||
return this.Posts.Any(x => x.IsActive) && (this.HasBar || this.HasBaz); | ||
} | ||
} | ||
} | ||
|
||
|
||
[Test] | ||
public void Test() | ||
{ | ||
Expression<Func<Blog, bool>> expected = b => b.HasBar ? b.Posts.Any(x => x.IsActive) : (b.HasBaz && b.Posts.Any(x => x.IsActive)); | ||
Func<Blog, bool> compiled = b => b.HasFoo; | ||
|
||
Test(expected, compiled); | ||
} | ||
|
||
[Test] | ||
public void Test2() | ||
{ | ||
Expression<Func<Blog, bool>> expected = b => b.Posts.Any(x => x.IsActive) && (b.HasBar ? true : b.HasBaz); | ||
Func<Blog, bool> compiled = b => b.HasFoo3; | ||
|
||
Test(expected, compiled); | ||
} | ||
} | ||
} |