-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db6ce60
commit 3bfb8f8
Showing
74 changed files
with
1,048 additions
and
549 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
Tests/RCommon.ApplicationServices.Tests/RCommon.ApplicationServices.Tests.csproj
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,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageReference Include="Moq" Version="4.20.72" /> | ||
<PackageReference Include="NUnit" Version="4.2.2" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="4.3.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Src\RCommon.ApplicationServices\RCommon.ApplicationServices.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,63 @@ | ||
using Moq; | ||
using NUnit.Framework; | ||
using RCommon.Caching; | ||
using System; | ||
|
||
namespace RCommon.Caching.Tests | ||
{ | ||
[TestFixture] | ||
public class CacheKeyTests | ||
{ | ||
private MockRepository mockRepository; | ||
|
||
|
||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.mockRepository = new MockRepository(MockBehavior.Strict); | ||
|
||
|
||
} | ||
|
||
private CacheKey CreateCacheKey() | ||
{ | ||
return new CacheKey( | ||
TODO); | ||
} | ||
|
||
[Test] | ||
public void With_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var cacheKey = this.CreateCacheKey(); | ||
string[] keys = null; | ||
|
||
// Act | ||
var result = cacheKey.With( | ||
keys); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void With_StateUnderTest_ExpectedBehavior1() | ||
{ | ||
// Arrange | ||
var cacheKey = this.CreateCacheKey(); | ||
Type ownerType = null; | ||
string[] keys = null; | ||
|
||
// Act | ||
var result = cacheKey.With( | ||
ownerType, | ||
keys); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
} | ||
} |
File renamed without changes.
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,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageReference Include="Moq" Version="4.20.72" /> | ||
<PackageReference Include="NUnit" Version="4.2.2" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="4.3.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Src\RCommon.Caching\RCommon.Caching.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
78 changes: 78 additions & 0 deletions
78
Tests/RCommon.Core.Tests/EventHandling/InMemoryEventBusTests.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,78 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Moq; | ||
using NUnit.Framework; | ||
using RCommon.EventHandling; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace RCommon.Core.Tests.EventHandling | ||
{ | ||
[TestFixture] | ||
public class InMemoryEventBusTests | ||
{ | ||
private MockRepository mockRepository; | ||
|
||
private Mock<IServiceProvider> mockServiceProvider; | ||
private Mock<IServiceCollection> mockServiceCollection; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.mockRepository = new MockRepository(MockBehavior.Strict); | ||
|
||
this.mockServiceProvider = this.mockRepository.Create<IServiceProvider>(); | ||
this.mockServiceCollection = this.mockRepository.Create<IServiceCollection>(); | ||
} | ||
|
||
private InMemoryEventBus CreateInMemoryEventBus() | ||
{ | ||
return new InMemoryEventBus( | ||
this.mockServiceProvider.Object, | ||
this.mockServiceCollection.Object); | ||
} | ||
|
||
[Test] | ||
public void Subscribe_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var inMemoryEventBus = this.CreateInMemoryEventBus(); | ||
|
||
// Act | ||
var result = inMemoryEventBus.Subscribe(); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void SubscribeAllHandledEvents_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var inMemoryEventBus = this.CreateInMemoryEventBus(); | ||
|
||
// Act | ||
var result = inMemoryEventBus.SubscribeAllHandledEvents(); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public async Task PublishAsync_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var inMemoryEventBus = this.CreateInMemoryEventBus(); | ||
TEvent @event = default(TEvent); | ||
|
||
// Act | ||
await inMemoryEventBus.PublishAsync( | ||
@event); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
Tests/RCommon.Core.Tests/EventHandling/Producers/InMemoryTransactionalEventRouterTests.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,96 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using NUnit.Framework; | ||
using RCommon.EventHandling.Producers; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace RCommon.Core.Tests.EventHandling.Producers | ||
{ | ||
[TestFixture] | ||
public class InMemoryTransactionalEventRouterTests | ||
{ | ||
private MockRepository mockRepository; | ||
|
||
private Mock<IServiceProvider> mockServiceProvider; | ||
private Mock<ILogger<InMemoryTransactionalEventRouter>> mockLogger; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.mockRepository = new MockRepository(MockBehavior.Strict); | ||
|
||
this.mockServiceProvider = this.mockRepository.Create<IServiceProvider>(); | ||
this.mockLogger = this.mockRepository.Create<ILogger<InMemoryTransactionalEventRouter>>(); | ||
} | ||
|
||
private InMemoryTransactionalEventRouter CreateInMemoryTransactionalEventRouter() | ||
{ | ||
return new InMemoryTransactionalEventRouter( | ||
this.mockServiceProvider.Object, | ||
this.mockLogger.Object); | ||
} | ||
|
||
[Test] | ||
public async Task RouteEventsAsync_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var inMemoryTransactionalEventRouter = this.CreateInMemoryTransactionalEventRouter(); | ||
IEnumerable transactionalEvents = null; | ||
|
||
// Act | ||
await inMemoryTransactionalEventRouter.RouteEventsAsync( | ||
transactionalEvents); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public async Task RouteEventsAsync_StateUnderTest_ExpectedBehavior1() | ||
{ | ||
// Arrange | ||
var inMemoryTransactionalEventRouter = this.CreateInMemoryTransactionalEventRouter(); | ||
|
||
// Act | ||
await inMemoryTransactionalEventRouter.RouteEventsAsync(); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void AddTransactionalEvent_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var inMemoryTransactionalEventRouter = this.CreateInMemoryTransactionalEventRouter(); | ||
ISerializableEvent serializableEvent = null; | ||
|
||
// Act | ||
inMemoryTransactionalEventRouter.AddTransactionalEvent( | ||
serializableEvent); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void AddTransactionalEvents_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var inMemoryTransactionalEventRouter = this.CreateInMemoryTransactionalEventRouter(); | ||
IEnumerable serializableEvents = null; | ||
|
||
// Act | ||
inMemoryTransactionalEventRouter.AddTransactionalEvents( | ||
serializableEvents); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Tests/RCommon.Core.Tests/EventHandling/Producers/PublishWithEventBusEventProducerTests.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,53 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using NUnit.Framework; | ||
using RCommon.EventHandling; | ||
using RCommon.EventHandling.Producers; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace RCommon.Core.Tests.EventHandling.Producers | ||
{ | ||
[TestFixture] | ||
public class PublishWithEventBusEventProducerTests | ||
{ | ||
private MockRepository mockRepository; | ||
|
||
private Mock<IEventBus> mockEventBus; | ||
private Mock<ILogger<PublishWithEventBusEventProducer>> mockLogger; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.mockRepository = new MockRepository(MockBehavior.Strict); | ||
|
||
this.mockEventBus = this.mockRepository.Create<IEventBus>(); | ||
this.mockLogger = this.mockRepository.Create<ILogger<PublishWithEventBusEventProducer>>(); | ||
} | ||
|
||
private PublishWithEventBusEventProducer CreatePublishWithEventBusEventProducer() | ||
{ | ||
return new PublishWithEventBusEventProducer( | ||
this.mockEventBus.Object, | ||
this.mockLogger.Object); | ||
} | ||
|
||
[Test] | ||
public async Task ProduceEventAsync_StateUnderTest_ExpectedBehavior() | ||
{ | ||
// Arrange | ||
var publishWithEventBusEventProducer = this.CreatePublishWithEventBusEventProducer(); | ||
T @event = default(T); | ||
CancellationToken cancellationToken = default(global::System.Threading.CancellationToken); | ||
|
||
// Act | ||
await publishWithEventBusEventProducer.ProduceEventAsync( | ||
@event, | ||
cancellationToken); | ||
|
||
// Assert | ||
Assert.Fail(); | ||
this.mockRepository.VerifyAll(); | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.