completed tests for in :)
This commit is contained in:
		
							parent
							
								
									d9547fd544
								
							
						
					
					
						commit
						74a68c70c1
					
				| @ -101,65 +101,7 @@ namespace PoweredSoft.DynamicLinq.Test | |||||||
|         [TestMethod] |         [TestMethod] | ||||||
|         public void TestAutomaticNullChecking() |         public void TestAutomaticNullChecking() | ||||||
|         { |         { | ||||||
|             var authors = new List<Author>() |             var authors = TestData.Authors; | ||||||
|             { |  | ||||||
|                 new Author |  | ||||||
|                 { |  | ||||||
|                     Id = 1, |  | ||||||
|                     FirstName = "David", |  | ||||||
|                     LastName = "Lebee", |  | ||||||
|                     Posts = new List<Post> |  | ||||||
|                     { |  | ||||||
|                         new Post |  | ||||||
|                         { |  | ||||||
|                             Id = 1, |  | ||||||
|                             AuthorId = 1, |  | ||||||
|                             Title = "Match", |  | ||||||
|                             Content = "ABC", |  | ||||||
|                             Comments = new List<Comment>() |  | ||||||
|                             { |  | ||||||
|                                 new Comment() |  | ||||||
|                                 { |  | ||||||
|                                     Id = 1, |  | ||||||
|                                     DisplayName = "John Doe", |  | ||||||
|                                     CommentText = "!@#$!@#!@#", |  | ||||||
|                                     Email = "john.doe@me.com" |  | ||||||
|                                 } |  | ||||||
|                             } |  | ||||||
|                         }, |  | ||||||
|                         new Post |  | ||||||
|                         { |  | ||||||
|                             Id = 2, |  | ||||||
|                             AuthorId = 1, |  | ||||||
|                             Title = "Match", |  | ||||||
|                             Content = "ABC" |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 }, |  | ||||||
|                 new Author |  | ||||||
|                 { |  | ||||||
|                     Id = 2, |  | ||||||
|                     FirstName = "Chuck", |  | ||||||
|                     LastName = "Norris", |  | ||||||
|                     Posts = new List<Post> |  | ||||||
|                     { |  | ||||||
|                         new Post |  | ||||||
|                         { |  | ||||||
|                             Id = 3, |  | ||||||
|                             AuthorId = 2, |  | ||||||
|                             Title = "Match", |  | ||||||
|                             Content = "ASD" |  | ||||||
|                         }, |  | ||||||
|                         new Post |  | ||||||
|                         { |  | ||||||
|                             Id = 4, |  | ||||||
|                             AuthorId = 2, |  | ||||||
|                             Title = "DontMatch", |  | ||||||
|                             Content = "ASD" |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             }; |  | ||||||
| 
 | 
 | ||||||
|             // the query. |             // the query. | ||||||
|             var query = authors.AsQueryable(); |             var query = authors.AsQueryable(); | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ using System.Collections.Generic; | |||||||
| using System.Linq; | using System.Linq; | ||||||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | using Microsoft.VisualStudio.TestTools.UnitTesting; | ||||||
| using PoweredSoft.DynamicLinq; | using PoweredSoft.DynamicLinq; | ||||||
|  | using PoweredSoft.DynamicLinq.Dal.Pocos; | ||||||
| using PoweredSoft.DynamicLinq.Test.Helpers; | using PoweredSoft.DynamicLinq.Test.Helpers; | ||||||
| 
 | 
 | ||||||
| namespace PoweredSoft.DynamicLinq.Test | namespace PoweredSoft.DynamicLinq.Test | ||||||
| @ -10,23 +11,13 @@ namespace PoweredSoft.DynamicLinq.Test | |||||||
|     [TestClass] |     [TestClass] | ||||||
|     public class InTests |     public class InTests | ||||||
|     { |     { | ||||||
|         internal List<MockPersonObject> Persons = new List<MockPersonObject> |  | ||||||
|         { |  | ||||||
|             new MockPersonObject { FirstName = "David", LastName = "Lebee", Age = 28 }, |  | ||||||
|             new MockPersonObject { FirstName = "Michaela", LastName = "Vickar", Age = 27 }, |  | ||||||
|             new MockPersonObject { FirstName = "John", LastName = "Doe", Age = 28 }, |  | ||||||
|             new MockPersonObject { FirstName = "Chuck", LastName = "Norris", Age = 50 }, |  | ||||||
|             new MockPersonObject { FirstName = "Michael", LastName = "Jackson", Age = 58 } |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         [TestMethod] |         [TestMethod] | ||||||
|         public void In() |         public void In() | ||||||
|         { |         { | ||||||
|             IQueryable<MockPersonObject> a, b; |             IQueryable<MockPersonObject> a, b; | ||||||
|             var ageGroup = new List<int>() { 28, 27, 50 }; |             var ageGroup = new List<int>() { 28, 27, 50 }; | ||||||
| 
 |             a = TestData.Persons.AsQueryable().Query(t => t.In("Age", ageGroup)); | ||||||
|             a = Persons.AsQueryable().Query(t => t.In("Age", ageGroup)); |             b = TestData.Persons.AsQueryable().Where(t => ageGroup.Contains(t.Age)); | ||||||
|             b = Persons.AsQueryable().Where(t => ageGroup.Contains(t.Age)); |  | ||||||
|             QueryableAssert.AreEqual(a, b); |             QueryableAssert.AreEqual(a, b); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -35,8 +26,8 @@ namespace PoweredSoft.DynamicLinq.Test | |||||||
|         { |         { | ||||||
|             IQueryable<MockPersonObject> a, b; |             IQueryable<MockPersonObject> a, b; | ||||||
|             var ageGroup = new List<int>() { 50, 58 }; |             var ageGroup = new List<int>() { 50, 58 }; | ||||||
|             a = Persons.AsQueryable().Query(t => t.NotIn("Age", ageGroup)); |             a = TestData.Persons.AsQueryable().Query(t => t.NotIn("Age", ageGroup)); | ||||||
|             b = Persons.AsQueryable().Where(t => !ageGroup.Contains(t.Age)); |             b = TestData.Persons.AsQueryable().Where(t => !ageGroup.Contains(t.Age)); | ||||||
|             QueryableAssert.AreEqual(a, b); |             QueryableAssert.AreEqual(a, b); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -45,8 +36,8 @@ namespace PoweredSoft.DynamicLinq.Test | |||||||
|         { |         { | ||||||
|             IQueryable<MockPersonObject> a, b; |             IQueryable<MockPersonObject> a, b; | ||||||
|             var group = new List<string>() { "David", "Michaela" }; |             var group = new List<string>() { "David", "Michaela" }; | ||||||
|             a = Persons.AsQueryable().Query(t => t.In("FirstName", group)); |             a = TestData.Persons.AsQueryable().Query(t => t.In("FirstName", group)); | ||||||
|             b = Persons.AsQueryable().Where(t => group.Contains(t.FirstName)); |             b = TestData.Persons.AsQueryable().Where(t => group.Contains(t.FirstName)); | ||||||
|             QueryableAssert.AreEqual(a, b); |             QueryableAssert.AreEqual(a, b); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -57,8 +48,26 @@ namespace PoweredSoft.DynamicLinq.Test | |||||||
|             var ageGroup = new List<string>() { "28", "27", "50" }; |             var ageGroup = new List<string>() { "28", "27", "50" }; | ||||||
|             var ageGroupInt = ageGroup.Select(t => Convert.ToInt32(t)).ToList(); |             var ageGroupInt = ageGroup.Select(t => Convert.ToInt32(t)).ToList(); | ||||||
| 
 | 
 | ||||||
|             a = Persons.AsQueryable().Query(t => t.In("Age", ageGroup)); |             a = TestData.Persons.AsQueryable().Query(t => t.In("Age", ageGroup)); | ||||||
|             b = Persons.AsQueryable().Where(t => ageGroupInt.Contains(t.Age)); |             b = TestData.Persons.AsQueryable().Where(t => ageGroupInt.Contains(t.Age)); | ||||||
|  |             QueryableAssert.AreEqual(a, b); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         [TestMethod] | ||||||
|  |         public void MixingInWithCollectionPaths() | ||||||
|  |         { | ||||||
|  |             var titles = new List<string>() { "Match" }; | ||||||
|  |             var a = TestData.Authors.AsQueryable().Query(t => t.In("Posts.Title", titles)); | ||||||
|  |             var b = TestData.Authors.AsQueryable().Where(t => t.Posts.Any(t2 => titles.Contains(t2.Title))); | ||||||
|  |             QueryableAssert.AreEqual(a, b); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         [TestMethod] | ||||||
|  |         public void MixingInComplexPaths() | ||||||
|  |         { | ||||||
|  |             var authorsFirstNames = new List<string>() { "David", "Pablo" }; | ||||||
|  |             var a = TestData.Posts.AsQueryable().Query(t => t.In("Author.FirstName", authorsFirstNames)); | ||||||
|  |             var b = TestData.Posts.AsQueryable().Where(t => authorsFirstNames.Contains(t.Author.FirstName)); | ||||||
|             QueryableAssert.AreEqual(a, b); |             QueryableAssert.AreEqual(a, b); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -70,6 +70,7 @@ | |||||||
|     <Compile Include="HelpersTests.cs" /> |     <Compile Include="HelpersTests.cs" /> | ||||||
|     <Compile Include="EntityFrameworkTests.cs" /> |     <Compile Include="EntityFrameworkTests.cs" /> | ||||||
|     <Compile Include="StringComparision.cs" /> |     <Compile Include="StringComparision.cs" /> | ||||||
|  |     <Compile Include="TestData.cs" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <None Include="packages.config" /> |     <None Include="packages.config" /> | ||||||
|  | |||||||
| @ -10,14 +10,7 @@ namespace PoweredSoft.DynamicLinq.Test | |||||||
|     [TestClass] |     [TestClass] | ||||||
|     public class StringComparisionTests |     public class StringComparisionTests | ||||||
|     { |     { | ||||||
|         internal List<MockPersonObject> Persons = new List<MockPersonObject> |         internal List<MockPersonObject> Persons => TestData.Persons; | ||||||
|         { |  | ||||||
|             new MockPersonObject { FirstName = "David", LastName = "Lebee", Age = 28 }, |  | ||||||
|             new MockPersonObject { FirstName = "Michaela", LastName = "Vickar", Age = 27 }, |  | ||||||
|             new MockPersonObject { FirstName = "John", LastName = "Doe", Age = 28 }, |  | ||||||
|             new MockPersonObject { FirstName = "Chuck", LastName = "Norris", Age = 50 }, |  | ||||||
|             new MockPersonObject { FirstName = "Michael", LastName = "Jackson", Age = 58 } |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         [TestMethod] |         [TestMethod] | ||||||
|         public void Equal() |         public void Equal() | ||||||
|  | |||||||
							
								
								
									
										127
									
								
								PoweredSoft.DynamicLinq.Test/TestData.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								PoweredSoft.DynamicLinq.Test/TestData.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,127 @@ | |||||||
|  | using PoweredSoft.DynamicLinq.Dal.Pocos; | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  | 
 | ||||||
|  | namespace PoweredSoft.DynamicLinq.Test | ||||||
|  | { | ||||||
|  |     internal static class TestData | ||||||
|  |     { | ||||||
|  |         static readonly internal List<MockPersonObject> Persons = new List<MockPersonObject> | ||||||
|  |         { | ||||||
|  |             new MockPersonObject { FirstName = "David", LastName = "Lebee", Age = 28 }, | ||||||
|  |             new MockPersonObject { FirstName = "Michaela", LastName = "Vickar", Age = 27 }, | ||||||
|  |             new MockPersonObject { FirstName = "John", LastName = "Doe", Age = 28 }, | ||||||
|  |             new MockPersonObject { FirstName = "Chuck", LastName = "Norris", Age = 50 }, | ||||||
|  |             new MockPersonObject { FirstName = "Michael", LastName = "Jackson", Age = 58 } | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         static readonly internal List<Post> Posts = new List<Post>() | ||||||
|  |         { | ||||||
|  |             new Post | ||||||
|  |             { | ||||||
|  |                 Id = 1, | ||||||
|  |                 Author = new Author() | ||||||
|  |                 { | ||||||
|  |                     Id = 1, | ||||||
|  |                     FirstName = "David", | ||||||
|  |                     LastName = "Lebee" | ||||||
|  |                 }, | ||||||
|  |                 AuthorId = 1, | ||||||
|  |                 CreateTime = DateTime.Now, | ||||||
|  |                 Title = "Match", | ||||||
|  |                 Content = "ABC", | ||||||
|  |             }, | ||||||
|  |             new Post | ||||||
|  |             { | ||||||
|  |                 Id = 2, | ||||||
|  |                 Author = new Author() | ||||||
|  |                 { | ||||||
|  |                     Id = 1, | ||||||
|  |                     FirstName = "David", | ||||||
|  |                     LastName = "Lebee" | ||||||
|  |                 }, | ||||||
|  |                 AuthorId = 1, | ||||||
|  |                 CreateTime = DateTime.Now, | ||||||
|  |                 Title = "Match 2", | ||||||
|  |                 Content = "ABC 2", | ||||||
|  |             }, | ||||||
|  |             new Post | ||||||
|  |             { | ||||||
|  |                 Id = 3, | ||||||
|  |                 Author = new Author() | ||||||
|  |                 { | ||||||
|  |                     Id = 2, | ||||||
|  |                     FirstName = "John", | ||||||
|  |                     LastName = "Doe" | ||||||
|  |                 }, | ||||||
|  |                 AuthorId = 3, | ||||||
|  |                 CreateTime = DateTime.Now, | ||||||
|  |                 Title = "Match 3", | ||||||
|  |                 Content = "ABC 3", | ||||||
|  |             }, | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         static readonly internal List<Author> Authors = new List<Author>() | ||||||
|  |         { | ||||||
|  |             new Author | ||||||
|  |             { | ||||||
|  |                 Id = 1, | ||||||
|  |                 FirstName = "David", | ||||||
|  |                 LastName = "Lebee", | ||||||
|  |                 Posts = new List<Post> | ||||||
|  |                 { | ||||||
|  |                     new Post | ||||||
|  |                     { | ||||||
|  |                         Id = 1, | ||||||
|  |                         AuthorId = 1, | ||||||
|  |                         Title = "Match", | ||||||
|  |                         Content = "ABC", | ||||||
|  |                         Comments = new List<Comment>() | ||||||
|  |                         { | ||||||
|  |                             new Comment() | ||||||
|  |                             { | ||||||
|  |                                 Id = 1, | ||||||
|  |                                 DisplayName = "John Doe", | ||||||
|  |                                 CommentText = "!@#$!@#!@#", | ||||||
|  |                                 Email = "john.doe@me.com" | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     }, | ||||||
|  |                     new Post | ||||||
|  |                     { | ||||||
|  |                         Id = 2, | ||||||
|  |                         AuthorId = 1, | ||||||
|  |                         Title = "Match", | ||||||
|  |                         Content = "ABC" | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             }, | ||||||
|  |             new Author | ||||||
|  |             { | ||||||
|  |                 Id = 2, | ||||||
|  |                 FirstName = "Chuck", | ||||||
|  |                 LastName = "Norris", | ||||||
|  |                 Posts = new List<Post> | ||||||
|  |                 { | ||||||
|  |                     new Post | ||||||
|  |                     { | ||||||
|  |                         Id = 3, | ||||||
|  |                         AuthorId = 2, | ||||||
|  |                         Title = "Match", | ||||||
|  |                         Content = "ASD" | ||||||
|  |                     }, | ||||||
|  |                     new Post | ||||||
|  |                     { | ||||||
|  |                         Id = 4, | ||||||
|  |                         AuthorId = 2, | ||||||
|  |                         Title = "DontMatch", | ||||||
|  |                         Content = "ASD" | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         }; | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user