forked from rsm-hcd/RSM.HCD.CSharp
-
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.
Issue rsm-hcd#34 and rsm-hcd#17: Implemented BulkCreateDistinctAsync …
…and some clean up
- Loading branch information
Showing
12 changed files
with
159 additions
and
35 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
16 changes: 16 additions & 0 deletions
16
src/Core/Interfaces/Conductors/IRepositoryConductorAsync.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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace AndcultureCode.CSharp.Core.Interfaces.Conductors | ||
{ | ||
public partial interface IRepositoryConductor<T> : IConductor, | ||
IRepositoryCreateConductor<T>, | ||
IRepositoryDeleteConductor<T>, | ||
IRepositoryReadConductor<T>, | ||
IRepositoryUpdateConductor<T> | ||
where T : Models.Entities.Entity | ||
{ | ||
|
||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
test/Conductors.Tests/RepositoryConductorTests/BulkCreateDistinctAsyncShould.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,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AndcultureCode.CSharp.Core.Interfaces.Conductors; | ||
using AndcultureCode.CSharp.Testing.Models.Stubs; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
|
||
namespace AndcultureCode.CSharp.Conductors.Tests.RepositoryConductorTests | ||
{ | ||
public class BulkCreateDistinctAsyncShould : ProjectUnitTest | ||
{ | ||
public BulkCreateDistinctAsyncShould(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
private IRepositoryConductor<UserStub> SetupSut( | ||
IRepositoryMock<UserStub> repositoryMock | ||
) | ||
{ | ||
var repositoryCreateConductor = new RepositoryCreateConductor<UserStub>(repositoryMock.Object); | ||
return new RepositoryConductor<UserStub>( | ||
createConductor: repositoryCreateConductor, | ||
deleteConductor: null, | ||
readConductor: null, | ||
updateConductor: null | ||
); | ||
} | ||
|
||
[Fact] | ||
public async Task Throw_Argument_Null_Exception_When_Given_Null_Input() | ||
{ | ||
// Arrange | ||
var repositoryMock = new IRepositoryMock<UserStub>(); | ||
var respositoryConductor = SetupSut(repositoryMock); | ||
|
||
// Act & Assert | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => respositoryConductor.BulkCreateAsync(null)); | ||
} | ||
|
||
[Fact] | ||
public async Task Throw_Argument_Exception_When_Given_Empty_Input() | ||
{ | ||
// Arrange | ||
var repositoryMock = new IRepositoryMock<UserStub>(); | ||
var respositoryConductor = SetupSut(repositoryMock); | ||
|
||
// Act & Assert | ||
await Assert.ThrowsAsync<ArgumentException>(() => respositoryConductor.BulkCreateAsync(new List<UserStub>())); | ||
} | ||
|
||
[Fact] | ||
public async Task Throw_Stop_If_Canceled() | ||
{ | ||
// Arrange | ||
var repositoryMock = new IRepositoryMock<UserStub>(); | ||
var respositoryConductor = SetupSut(repositoryMock); | ||
var cancellationTokenSource = new CancellationTokenSource(); | ||
var cancellationToken = cancellationTokenSource.Token; | ||
cancellationTokenSource.Cancel(); | ||
// Act & Assert | ||
await Assert.ThrowsAsync<OperationCanceledException>(() => respositoryConductor.BulkCreateAsync(new List<UserStub>(), 5, cancellationToken)); | ||
} | ||
} | ||
} |
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