-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Tests for ObservableConsumer * Moved ConfigurationException to Abstractions and added tests * Extracted test utils * Version bump to 1.0.0-alpha0002 * Skip coveralls when building PRs
- Loading branch information
Showing
23 changed files
with
302 additions
and
211 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
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
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,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Nybus; | ||
|
||
namespace Tests | ||
{ | ||
public class FirstTestCommand : ICommand | ||
{ | ||
public string Message { get; set; } | ||
} | ||
|
||
public class SecondTestCommand : ICommand { } | ||
|
||
public class FirstTestCommandHandler : ICommandHandler<FirstTestCommand> | ||
{ | ||
public Task HandleAsync(IDispatcher dispatcher, ICommandContext<FirstTestCommand> incomingCommand) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Nybus; | ||
using Nybus.Utils; | ||
|
||
namespace Tests | ||
{ | ||
public class FirstTestEvent : IEvent { } | ||
|
||
public class SecondTestEvent : IEvent { } | ||
|
||
public class FirstTestEventHandler : IEventHandler<FirstTestEvent> | ||
{ | ||
public Task HandleAsync(IDispatcher dispatcher, IEventContext<FirstTestEvent> incomingEvent) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Nybus.Utils; | ||
|
||
namespace Tests | ||
{ | ||
public class TestClock : IClock | ||
{ | ||
public TestClock(DateTimeOffset initialTime) | ||
{ | ||
Now = initialTime; | ||
} | ||
|
||
public TestClock() : this(DateTimeOffset.UtcNow) | ||
{ | ||
|
||
} | ||
|
||
public DateTimeOffset Now { get; private set; } | ||
|
||
public void AdvanceBy(TimeSpan interval) | ||
{ | ||
Now += interval; | ||
} | ||
|
||
public void SetTo(DateTimeOffset newValue) | ||
{ | ||
Now = newValue; | ||
} | ||
} | ||
} |
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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Nybus.Configuration; | ||
|
||
namespace Tests | ||
{ | ||
public class TestNybusConfigurator : INybusConfigurator | ||
{ | ||
public void UseConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration, string sectionName = "Nybus") | ||
{ | ||
Configuration = configuration.GetSection(sectionName); | ||
} | ||
|
||
private readonly List<Action<IServiceCollection>> _serviceConfigurations = new List<Action<IServiceCollection>>(); | ||
|
||
public void AddServiceConfiguration(Action<IServiceCollection> configurator) | ||
{ | ||
_serviceConfigurations.Add(configurator); | ||
} | ||
|
||
public void ApplyServiceConfigurations(IServiceCollection services) | ||
{ | ||
foreach (var sc in _serviceConfigurations) | ||
sc(services); | ||
} | ||
|
||
private readonly List<Action<ISubscriptionBuilder>> _subscriptionBuilders = new List<Action<ISubscriptionBuilder>>(); | ||
|
||
public void AddSubscription(Action<ISubscriptionBuilder> configurator) | ||
{ | ||
_subscriptionBuilders.Add(configurator); | ||
} | ||
|
||
public void ApplySubscriptions(ISubscriptionBuilder builder) | ||
{ | ||
foreach (var sb in _subscriptionBuilders) | ||
sb(builder); | ||
} | ||
|
||
public Microsoft.Extensions.Configuration.IConfiguration Configuration { get; private set; } | ||
|
||
public void Configure(Action<INybusConfiguration> configuration) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Nybus.Abstractions\Nybus.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file was deleted.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
tests/Tests.Nybus.Abstractions/Configuration/ConfigurationExceptionTests.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,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Nybus.Configuration; | ||
|
||
namespace Tests.Configuration | ||
{ | ||
[TestFixture] | ||
public class ConfigurationExceptionTests | ||
{ | ||
[Test, AutoMoqData] | ||
public void ConfigurationException_can_be_built_with_message(string message) | ||
{ | ||
var sut = new ConfigurationException(message); | ||
|
||
Assert.That(sut.Message, Is.EqualTo(message)); | ||
} | ||
|
||
[Test, AutoMoqData] | ||
public void ConfigurationException_can_be_built_with_message_and_innerException(string message, Exception innerException) | ||
{ | ||
var sut = new ConfigurationException(message, innerException); | ||
|
||
Assert.That(sut.Message, Is.EqualTo(message)); | ||
|
||
Assert.That(sut.InnerException, Is.SameAs(innerException)); | ||
} | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
tests/Tests.Nybus.Engine.RabbitMq/Configuration/RabbitMqConfigurationTests.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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Nybus.Configuration; | ||
using RabbitMQ.Client; | ||
|
||
namespace Tests.Configuration | ||
{ | ||
|
||
[TestFixture] | ||
public class RabbitMqConfigurationTests | ||
{ | ||
[Test, AutoMoqData] | ||
public void Serializer_can_be_assigned(RabbitMqConfiguration sut, ISerializer serializer) | ||
{ | ||
sut.Serializer = serializer; | ||
|
||
Assert.That(sut.Serializer, Is.SameAs(serializer)); | ||
} | ||
|
||
[Test, AutoMoqData] | ||
public void Serializer_can_be_accessed(RabbitMqConfiguration sut) | ||
{ | ||
Assert.That(sut.Serializer, Is.Not.Null); | ||
} | ||
|
||
[Test, AutoMoqData] | ||
public void ConnectionFactory_can_be_assigned(RabbitMqConfiguration sut, IConnectionFactory connectionFactory) | ||
{ | ||
sut.ConnectionFactory = connectionFactory; | ||
|
||
Assert.That(sut.ConnectionFactory, Is.SameAs(connectionFactory)); | ||
} | ||
|
||
[Test, AutoMoqData] | ||
public void ConnectionFactory_can_be_accessed(RabbitMqConfiguration sut) | ||
{ | ||
Assert.That(sut.ConnectionFactory, Is.Not.Null); | ||
} | ||
} | ||
} |
Oops, something went wrong.