-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added SelectMany support * Renamed ISpecification SelectManyExpression to SelectorMany to match existing Selector * Added repository integration tests for SelectMany spec
- Loading branch information
Showing
16 changed files
with
162 additions
and
17 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
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
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
19 changes: 19 additions & 0 deletions
19
Specification/src/Ardalis.Specification/Exceptions/ConcurrentSelectorsException.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,19 @@ | ||
using System; | ||
|
||
namespace Ardalis.Specification | ||
{ | ||
public class ConcurrentSelectorsException : Exception | ||
{ | ||
private const string message = "Concurrent specification selector transforms defined. Ensure only one of the Select() or SelectMany() transforms is used in the same specification!"; | ||
|
||
public ConcurrentSelectorsException() | ||
: base(message) | ||
{ | ||
} | ||
|
||
public ConcurrentSelectorsException(Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
} | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
Specification/src/Ardalis.Specification/Exceptions/SelectorNotFoundException.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
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
25 changes: 25 additions & 0 deletions
25
...Ardalis.Specification.UnitTests/BuilderTests/SpecificationBuilderExtensions_SelectMany.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,25 @@ | ||
using Ardalis.Specification.UnitTests.Fixture.Specs; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Ardalis.Specification.UnitTests | ||
{ | ||
public class SpecificationBuilderExtensions_SelectMany | ||
{ | ||
[Fact] | ||
public void SetsNothing_GivenNoSelectManyExpression() | ||
{ | ||
var spec = new StoreProductNamesEmptySpec(); | ||
|
||
spec.SelectorMany.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void SetsSelectorMany_GivenSelectManyExpression() | ||
{ | ||
var spec = new StoreProductNamesSpec(); | ||
|
||
spec.SelectorMany.Should().NotBeNull(); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...tests/Ardalis.Specification.UnitTests/ExceptionTests/ConcurrentSelectorsExceptionTests.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,28 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Ardalis.Specification.UnitTests | ||
{ | ||
public class ConcurrentSelectorsExceptionTests | ||
{ | ||
private const string defaultMessage = "Concurrent specification selector transforms defined. Ensure only one of the Select() or SelectMany() transforms is used in the same specification!"; | ||
|
||
[Fact] | ||
public void ThrowWithDefaultConstructor() | ||
{ | ||
Action action = () => throw new ConcurrentSelectorsException(); | ||
|
||
action.Should().Throw<ConcurrentSelectorsException>().WithMessage(defaultMessage); | ||
} | ||
|
||
[Fact] | ||
public void ThrowWithInnerException() | ||
{ | ||
Exception inner = new Exception("test"); | ||
Action action = () => throw new ConcurrentSelectorsException(inner); | ||
|
||
action.Should().Throw<ConcurrentSelectorsException>().WithMessage(defaultMessage).WithInnerException<Exception>().WithMessage("test"); | ||
} | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
...on/tests/Ardalis.Specification.UnitTests/ExceptionTests/SelectorNotFoundExceptionTests.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
9 changes: 5 additions & 4 deletions
9
Specification/tests/Ardalis.Specification.UnitTests/Fixture/Entities/Seeds/ProductSeed.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
12 changes: 12 additions & 0 deletions
12
...ication/tests/Ardalis.Specification.UnitTests/Fixture/Specs/StoreProductNamesEmptySpec.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,12 @@ | ||
using Ardalis.Specification.UnitTests.Fixture.Entities; | ||
|
||
namespace Ardalis.Specification.UnitTests.Fixture.Specs | ||
{ | ||
public class StoreProductNamesEmptySpec : Specification<Store, string?> | ||
{ | ||
public StoreProductNamesEmptySpec() | ||
{ | ||
|
||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Specification/tests/Ardalis.Specification.UnitTests/Fixture/Specs/StoreProductNamesSpec.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,13 @@ | ||
using System.Linq; | ||
using Ardalis.Specification.UnitTests.Fixture.Entities; | ||
|
||
namespace Ardalis.Specification.UnitTests.Fixture.Specs | ||
{ | ||
public class StoreProductNamesSpec : Specification<Store, string?> | ||
{ | ||
public StoreProductNamesSpec() | ||
{ | ||
Query.SelectMany(s => s.Products.Select(p => p.Name)); | ||
} | ||
} | ||
} |