Skip to content

Commit

Permalink
Update tests to AutoFixture 4.7.0 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kralizek committed Jan 26, 2019
1 parent 2ef4a7d commit e4c0308
Show file tree
Hide file tree
Showing 43 changed files with 263 additions and 499 deletions.
8 changes: 4 additions & 4 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.6.0" />
<PackageReference Include="AutoFixture.NUnit3" Version="4.6.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.6.0" />
<PackageReference Include="AutoFixture.Idioms" Version="4.6.0" />
<PackageReference Include="AutoFixture" Version="4.7.0" />
<PackageReference Include="AutoFixture.NUnit3" Version="4.7.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.7.0" />
<PackageReference Include="AutoFixture.Idioms" Version="4.7.0" />
<PackageReference Include="Moq" Version="4.10.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ public void UseBusEngine_registers_BusEngine(INybusConfigurator configurator, Te
}

[Test, CustomAutoMoqData]
public void ServiceConfigurator_delegate_is_registered(INybusConfigurator configurator, TestBusEngine engine)
public void ServiceConfigurator_delegate_is_registered(INybusConfigurator configurator, TestBusEngine engine, Action<IServiceCollection> serviceConfigurator)
{
var serviceConfigurator = Mock.Of<Action<IServiceCollection>>();

NybusConfiguratorExtensions.UseBusEngine<TestBusEngine>(configurator, serviceConfigurator);

Mock.Get(configurator).Verify(p => p.AddServiceConfiguration(serviceConfigurator));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ public void NotifySuccess_returns_completed_task(InMemoryBusEngine sut, CommandM
}

[Test, CustomAutoMoqData]
public void NotifySuccess_raises_event(InMemoryBusEngine sut, CommandMessage<FirstTestCommand> testMessage)
public void NotifySuccess_raises_event(InMemoryBusEngine sut, CommandMessage<FirstTestCommand> testMessage, EventHandler<MessageEventArgs> handler)
{
var handler = Mock.Of <EventHandler<MessageEventArgs>>();
sut.OnMessageNotifySuccess += handler;

sut.NotifySuccessAsync(testMessage);
Expand All @@ -188,9 +187,8 @@ public void NotifySuccess_raises_event(InMemoryBusEngine sut, CommandMessage<Fir
}

[Test, CustomAutoMoqData]
public void NotifySuccess_raises_event(InMemoryBusEngine sut, EventMessage<FirstTestEvent> testMessage)
public void NotifySuccess_raises_event(InMemoryBusEngine sut, EventMessage<FirstTestEvent> testMessage, EventHandler<MessageEventArgs> handler)
{
var handler = Mock.Of<EventHandler<MessageEventArgs>>();
sut.OnMessageNotifySuccess += handler;

sut.NotifySuccessAsync(testMessage);
Expand Down Expand Up @@ -219,9 +217,8 @@ public void NotifyFail_returns_completed_task(InMemoryBusEngine sut, EventMessag
}

[Test, CustomAutoMoqData]
public void NotifyFail_raises_event(InMemoryBusEngine sut, CommandMessage<FirstTestCommand> testMessage)
public void NotifyFail_raises_event(InMemoryBusEngine sut, CommandMessage<FirstTestCommand> testMessage, EventHandler<MessageEventArgs> handler)
{
var handler = Mock.Of<EventHandler<MessageEventArgs>>();
sut.OnMessageNotifyFail += handler;

sut.NotifyFailAsync(testMessage);
Expand All @@ -232,9 +229,8 @@ public void NotifyFail_raises_event(InMemoryBusEngine sut, CommandMessage<FirstT
}

[Test, CustomAutoMoqData]
public void NotifyFail_raises_event(InMemoryBusEngine sut, EventMessage<FirstTestEvent> testMessage)
public void NotifyFail_raises_event(InMemoryBusEngine sut, EventMessage<FirstTestEvent> testMessage, EventHandler<MessageEventArgs> handler)
{
var handler = Mock.Of<EventHandler<MessageEventArgs>>();
sut.OnMessageNotifyFail += handler;

sut.NotifyFailAsync(testMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ public void HandleBasicCancel_accepts_departing_consumerTag(ObservableConsumer s
}

[Test, CustomAutoMoqData]
public void HandleBasicCancel_raise_ConsumerCancelled_event(ObservableConsumer sut, string consumerTag)
public void HandleBasicCancel_raise_ConsumerCancelled_event(ObservableConsumer sut, string consumerTag, EventHandler<ConsumerEventArgs> eventHandler)
{
var eventHandler = Mock.Of<EventHandler<ConsumerEventArgs>>();

sut.HandleBasicConsumeOk(consumerTag);

sut.ConsumerCancelled += eventHandler;
Expand All @@ -134,10 +132,8 @@ public void HandleBasicCancelOk_accepts_departing_consumerTag(ObservableConsumer
}

[Test, CustomAutoMoqData]
public void HandleBasicCancelOk_raise_ConsumerCancelled_event(ObservableConsumer sut, string consumerTag)
public void HandleBasicCancelOk_raise_ConsumerCancelled_event(ObservableConsumer sut, string consumerTag, EventHandler<ConsumerEventArgs> eventHandler)
{
var eventHandler = Mock.Of<EventHandler<ConsumerEventArgs>>();

sut.HandleBasicConsumeOk(consumerTag);

sut.ConsumerCancelled += eventHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ public void Handler_is_required()
}

[Test, CustomAutoMoqData]
public async Task Handler_is_executed(IDispatcher dispatcher, ICommandContext<FirstTestCommand> context)
public async Task Handler_is_executed(IDispatcher dispatcher, ICommandContext<FirstTestCommand> context, CommandReceivedAsync<FirstTestCommand> handler)
{
var handler = Mock.Of<CommandReceivedAsync<FirstTestCommand>>();

var sut = new DelegateWrapperCommandHandler<FirstTestCommand>(handler);

await sut.HandleAsync(dispatcher, context);
Expand All @@ -29,9 +27,8 @@ public async Task Handler_is_executed(IDispatcher dispatcher, ICommandContext<Fi
}

[Test, CustomAutoMoqData]
public void Handler_errors_are_not_caught(IDispatcher dispatcher, ICommandContext<FirstTestCommand> context, Exception error)
public void Handler_errors_are_not_caught(IDispatcher dispatcher, ICommandContext<FirstTestCommand> context, Exception error, CommandReceivedAsync<FirstTestCommand> handler)
{
var handler = Mock.Of<CommandReceivedAsync<FirstTestCommand>>();
Mock.Get(handler).Setup(p => p(It.IsAny<IDispatcher>(), It.IsAny<ICommandContext<FirstTestCommand>>())).Throws(error);

var sut = new DelegateWrapperCommandHandler<FirstTestCommand>(handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ public void Handler_is_required()
}

[Test, CustomAutoMoqData]
public async Task Handler_is_executed(IDispatcher dispatcher, IEventContext<FirstTestEvent> context)
public async Task Handler_is_executed(IDispatcher dispatcher, IEventContext<FirstTestEvent> context, EventReceivedAsync<FirstTestEvent> handler)
{
var handler = Mock.Of<EventReceivedAsync<FirstTestEvent>>();

var sut = new DelegateWrapperEventHandler<FirstTestEvent>(handler);

await sut.HandleAsync(dispatcher, context);
Expand All @@ -29,9 +27,8 @@ public async Task Handler_is_executed(IDispatcher dispatcher, IEventContext<Firs
}

[Test, CustomAutoMoqData]
public void Handler_errors_are_not_caught(IDispatcher dispatcher, IEventContext<FirstTestEvent> context, Exception error)
public void Handler_errors_are_not_caught(IDispatcher dispatcher, IEventContext<FirstTestEvent> context, Exception error, EventReceivedAsync<FirstTestEvent> handler)
{
var handler = Mock.Of<EventReceivedAsync<FirstTestEvent>>();
Mock.Get(handler).Setup(p => p(It.IsAny<IDispatcher>(), It.IsAny<IEventContext<FirstTestEvent>>())).Throws(error);

var sut = new DelegateWrapperEventHandler<FirstTestEvent>(handler);
Expand Down
12 changes: 3 additions & 9 deletions tests/Tests.Nybus/Configuration/NybusConfiguratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ public void AddServiceConfiguration_configures_given_service(NybusConfigurator s
}

[Test, CustomAutoMoqData]
public void AddServiceConfiguration_invokes_configuration_delegate(NybusConfigurator sut, IServiceCollection services)
public void AddServiceConfiguration_invokes_configuration_delegate(NybusConfigurator sut, IServiceCollection services, Action<IServiceCollection> configurationDelegate)
{
var configurationDelegate = Mock.Of<Action<IServiceCollection>>();

sut.AddServiceConfiguration(configurationDelegate);

sut.ConfigureServices(services);
Expand All @@ -39,10 +37,8 @@ public void AddServiceConfiguration_requires_non_null_configuration_delegate(Nyb
}

[Test, CustomAutoMoqData]
public void AddSubscription_configures(NybusConfigurator sut, ISubscriptionBuilder subscriptionBuilder)
public void AddSubscription_configures(NybusConfigurator sut, ISubscriptionBuilder subscriptionBuilder, Action<ISubscriptionBuilder> subscriptionDelegate)
{
var subscriptionDelegate = Mock.Of<Action<ISubscriptionBuilder>>();

sut.AddSubscription(subscriptionDelegate);

sut.ConfigureBuilder(subscriptionBuilder);
Expand Down Expand Up @@ -87,10 +83,8 @@ public void UseConfiguration_uses_default_sectionName(NybusConfigurator sut, ICo
}

[Test, CustomAutoMoqData]
public void Configure_(NybusConfigurator sut, IServiceProvider serviceProvider, INybusConfiguration configuration)
public void Configure_(NybusConfigurator sut, IServiceProvider serviceProvider, INybusConfiguration configuration, Action<INybusConfiguration> configurationDelegate)
{
var configurationDelegate = Mock.Of<Action<INybusConfiguration>>();

sut.Configure(configurationDelegate);

sut.CustomizeConfiguration(serviceProvider, configuration);
Expand Down
16 changes: 4 additions & 12 deletions tests/Tests.Nybus/Filters/DiscardErrorFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,24 @@ public void Constructor_is_guarded(GuardClauseAssertion assertion)
}

[Test, AutoMoqData]
public async Task HandleErrorAsync_notifies_engine_on_Command([Frozen] IBusEngine engine, DiscardErrorFilter sut, ICommandContext<FirstTestCommand> context, Exception exception)
public async Task HandleErrorAsync_notifies_engine_on_Command([Frozen] IBusEngine engine, DiscardErrorFilter sut, ICommandContext<FirstTestCommand> context, Exception exception, CommandErrorDelegate<FirstTestCommand> next)
{
var next = Mock.Of<CommandErrorDelegate<FirstTestCommand>>();

await sut.HandleErrorAsync(context, exception, next);

Mock.Get(engine).Verify(p => p.NotifyFailAsync(context.Message));
}

[Test, AutoMoqData]
public async Task HandleErrorAsync_notifies_engine_on_Event([Frozen] IBusEngine engine, DiscardErrorFilter sut, IEventContext<FirstTestEvent> context, Exception exception)
public async Task HandleErrorAsync_notifies_engine_on_Event([Frozen] IBusEngine engine, DiscardErrorFilter sut, IEventContext<FirstTestEvent> context, Exception exception, EventErrorDelegate<FirstTestEvent> next)
{
var next = Mock.Of<EventErrorDelegate<FirstTestEvent>>();

await sut.HandleErrorAsync(context, exception, next);

Mock.Get(engine).Verify(p => p.NotifyFailAsync(context.Message));
}

[Test, AutoMoqData]
public async Task HandleErrorAsync_forwards_to_next_if_error_on_Command([Frozen] IBusEngine engine, DiscardErrorFilter sut, ICommandContext<FirstTestCommand> context, Exception exception, Exception discardException)
public async Task HandleErrorAsync_forwards_to_next_if_error_on_Command([Frozen] IBusEngine engine, DiscardErrorFilter sut, ICommandContext<FirstTestCommand> context, Exception exception, Exception discardException, CommandErrorDelegate<FirstTestCommand> next)
{
var next = Mock.Of<CommandErrorDelegate<FirstTestCommand>>();

Mock.Get(engine).Setup(p => p.NotifyFailAsync(It.IsAny<Message>())).ThrowsAsync(discardException);

await sut.HandleErrorAsync(context, exception, next);
Expand All @@ -51,10 +45,8 @@ public async Task HandleErrorAsync_forwards_to_next_if_error_on_Command([Frozen]
}

[Test, AutoMoqData]
public async Task HandleErrorAsync_forwards_to_next_if_error_on_Event([Frozen] IBusEngine engine, DiscardErrorFilter sut, IEventContext<FirstTestEvent> context, Exception exception, Exception discardException)
public async Task HandleErrorAsync_forwards_to_next_if_error_on_Event([Frozen] IBusEngine engine, DiscardErrorFilter sut, IEventContext<FirstTestEvent> context, Exception exception, Exception discardException, EventErrorDelegate<FirstTestEvent> next)
{
var next = Mock.Of<EventErrorDelegate<FirstTestEvent>>();

Mock.Get(engine).Setup(p => p.NotifyFailAsync(It.IsAny<Message>())).ThrowsAsync(discardException);

await sut.HandleErrorAsync(context, exception, next);
Expand Down
8 changes: 2 additions & 6 deletions tests/Tests.Nybus/Filters/FallbackErrorFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ public void Constructor_is_guarded(GuardClauseAssertion assertion)
}

[Test, AutoMoqData]
public async Task HandleErrorAsync_notifies_engine_on_Command([Frozen] IBusEngine engine, FallbackErrorFilter sut, ICommandContext<FirstTestCommand> context, Exception exception)
public async Task HandleErrorAsync_notifies_engine_on_Command([Frozen] IBusEngine engine, FallbackErrorFilter sut, ICommandContext<FirstTestCommand> context, Exception exception, CommandErrorDelegate<FirstTestCommand> next)
{
var next = Mock.Of<CommandErrorDelegate<FirstTestCommand>>();

await sut.HandleErrorAsync(context, exception, next);

Mock.Get(engine).Verify(p => p.NotifyFailAsync(context.Message));
}

[Test, AutoMoqData]
public async Task HandleErrorAsync_notifies_engine_on_Event([Frozen] IBusEngine engine, FallbackErrorFilter sut, IEventContext<FirstTestEvent> context, Exception exception)
public async Task HandleErrorAsync_notifies_engine_on_Event([Frozen] IBusEngine engine, FallbackErrorFilter sut, IEventContext<FirstTestEvent> context, Exception exception, EventErrorDelegate<FirstTestEvent> next)
{
var next = Mock.Of<EventErrorDelegate<FirstTestEvent>>();

await sut.HandleErrorAsync(context, exception, next);

Mock.Get(engine).Verify(p => p.NotifyFailAsync(context.Message));
Expand Down
Loading

0 comments on commit e4c0308

Please sign in to comment.