Skip to content

Commit

Permalink
Merge pull request #25 from NerosoftDev/refactoring/service-bus
Browse files Browse the repository at this point in the history
Prevent run rabbitmq tests on github workflow.
  • Loading branch information
Codespilot authored Nov 29, 2023
2 parents 355101b + aa24c8d commit e780308
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Tests/Euonia.Bus.InMemory.Tests/Defines.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Nerosoft.Euonia.Bus.Tests;

internal partial class Defines
{
public const bool DontRunTests = false;

}
13 changes: 13 additions & 0 deletions Tests/Euonia.Bus.RabbitMq.Tests/Defines.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Nerosoft.Euonia.Bus.Tests;

internal partial class Defines
{
public const bool DontRunTests =
#if DEBUG
false
#else
true
#endif
;

}
6 changes: 6 additions & 0 deletions Tests/Euonia.Bus.Tests.Shared/Defines.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Nerosoft.Euonia.Bus.Tests;

internal partial class Defines
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Commands\FooCreateCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Commands\UserCreateCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Commands\UserUpdateCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Defines.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Handlers\FooCommandHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Handlers\UserCommandHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TestNotificationBucket.cs" />
Expand Down
16 changes: 16 additions & 0 deletions Tests/Euonia.Bus.Tests.Shared/ServiceBusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,43 @@ public ServiceBusTests(IBus bus)
[Fact]
public async Task TestSendCommand_HasReponse()
{
if (Defines.DontRunTests)
{
return;

Check warning on line 19 in Tests/Euonia.Bus.Tests.Shared/ServiceBusTests.cs

View workflow job for this annotation

GitHub Actions / build (6.0.x, Release)

Unreachable code detected
}
var result = await _bus.SendAsync<UserCreateCommand, int>(new UserCreateCommand());
Assert.Equal(1, result);
}

[Fact]
public async Task TestSendCommand_NoReponse()
{
if (Defines.DontRunTests)
{
return;
}
await _bus.SendAsync(new UserCreateCommand());
Assert.True(true);
}

[Fact]
public async Task TestSendCommand_HasReponse_UseSubscribeAttribute()
{
if (Defines.DontRunTests)
{
return;
}
var result = await _bus.SendAsync<FooCreateCommand, int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" });
Assert.Equal(1, result);
}

[Fact]
public async Task TestSendCommand_HasReponse_MessageHasResultInherites()
{
if (Defines.DontRunTests)
{
return;
}
var result = await _bus.SendAsync<int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" });
Assert.Equal(1, result);
}
Expand Down

0 comments on commit e780308

Please sign in to comment.