forked from ninjanye/SearchExtensions
-
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.
Enable searching wothing multiple child properties
- Loading branch information
Showing
7 changed files
with
173 additions
and
41 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...ns.Tests.Integration/Fluent/SearchTests/SearchChildren/SearchChildrenWithChainingTests.cs
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,55 @@ | ||
using System; | ||
using System.Linq; | ||
using NinjaNye.SearchExtensions.Tests.Integration.Models; | ||
using NUnit.Framework; | ||
|
||
namespace NinjaNye.SearchExtensions.Tests.Integration.Fluent.SearchTests.SearchChildren | ||
{ | ||
[TestFixture] | ||
internal class SearchChildrenWithChainingTests : IDisposable | ||
{ | ||
private readonly TestContext _context = new TestContext(); | ||
|
||
[Test] | ||
public void SearchChildren_SearchStringAndInteger_ResultsMatchBothOccurences() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var result = _context.TestModels.SearchChildren(x => x.Children) | ||
.With(c => c.IntegerOne) | ||
.EqualTo(101) | ||
.With(c => c.StringOne) | ||
.EqualTo("child test") | ||
.ToList(); | ||
|
||
//Assert | ||
Assert.That(result.Count, Is.EqualTo(1)); | ||
Assert.That(result.Any(tm => tm.Id == Guid.Parse("F672552D-2787-468D-8D2E-DE1E88F83E21"))); | ||
} | ||
|
||
[Test] | ||
public void SearchChildren_SearchIntegerAndString_ResultsMatchBothOccurences() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var result = _context.TestModels.SearchChildren(x => x.Children) | ||
.With(c => c.StringOne) | ||
.EqualTo("child test") | ||
.With(c => c.IntegerOne) | ||
.EqualTo(101) | ||
.ToList(); | ||
|
||
//Assert | ||
Assert.That(result.Count, Is.EqualTo(1)); | ||
Assert.That(result.Any(tm => tm.Id == Guid.Parse("F672552D-2787-468D-8D2E-DE1E88F83E21"))); | ||
} | ||
|
||
|
||
public void Dispose() | ||
{ | ||
this._context.Dispose(); | ||
} | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
...rchExtensions.Tests/SearchExtensionTests/IEnumerableTests/SearchChildrenChaingingTests.cs
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,55 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace NinjaNye.SearchExtensions.Tests.SearchExtensionTests.IEnumerableTests | ||
{ | ||
[TestFixture] | ||
public class SearchChildrenChaingingTests | ||
{ | ||
private ParentTestData _parent; | ||
private List<ParentTestData> _testData; | ||
private TestData _dataOne; | ||
private TestData _dataFour; | ||
private TestData _dataTwo; | ||
private TestData _dataThree; | ||
private ParentTestData _otherParent; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this._dataOne = new TestData {Name = "chris", Description = "child data", Number = 1, Age = 20}; | ||
this._dataTwo = new TestData {Name = "fred", Description = "child data", Number = 20, Age = 30}; | ||
this._dataThree = new TestData {Name = "teddy", Description = "child data", Number = 2, Age = 40}; | ||
this._dataFour = new TestData {Name = "josh", Description = "child data", Number = 20, Age = 50}; | ||
this._parent = new ParentTestData | ||
{ | ||
Children = new List<TestData> {this._dataOne, this._dataTwo}, | ||
}; | ||
this._otherParent = new ParentTestData | ||
{ | ||
Children = new List<TestData> {this._dataThree, this._dataFour}, | ||
}; | ||
this._testData = new List<ParentTestData> {this._parent, this._otherParent}; | ||
} | ||
|
||
[Test] | ||
public void SearchChildren_SearchStringAndInteger_ResultsMatchBothOccurences() | ||
{ | ||
//Arrange | ||
|
||
//Act | ||
var result = _testData.SearchChildren(x => x.Children) | ||
.With(c => c.Number) | ||
.EqualTo(20) | ||
.With(c => c.Name) | ||
.EqualTo("josh") | ||
.ToList(); | ||
|
||
//Assert | ||
Assert.That(result.Count, Is.EqualTo(1)); | ||
CollectionAssert.Contains(result, _otherParent); | ||
} | ||
|
||
} | ||
} |
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
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