-
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.
Merge pull request #28 from NerosoftDev/refactoring/service-bus
Refactor unit test.
- Loading branch information
Showing
3 changed files
with
128 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Nerosoft.Euonia.Bus.Tests.Commands; | ||
|
||
namespace Nerosoft.Euonia.Bus.Tests; | ||
|
||
public partial class ServiceBusTests | ||
{ | ||
private readonly IBus _bus; | ||
private readonly bool _dontRunTests; | ||
|
||
public ServiceBusTests(IBus bus, IConfiguration configuration) | ||
{ | ||
_bus = bus; | ||
_dontRunTests = configuration.GetValue<bool>("DontRunTests"); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse() | ||
{ | ||
var result = await _bus.SendAsync<UserCreateCommand, int>(new UserCreateCommand()); | ||
Assert.Equal(1, result); | ||
} | ||
|
||
public partial async Task TestSendCommand_NoReponse() | ||
{ | ||
await _bus.SendAsync(new UserCreateCommand()); | ||
Assert.True(true); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse_UseSubscribeAttribute() | ||
{ | ||
var result = await _bus.SendAsync<FooCreateCommand, int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" }); | ||
Assert.Equal(1, result); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse_MessageHasResultInherites() | ||
{ | ||
var result = await _bus.SendAsync<int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" }); | ||
Assert.Equal(1, result); | ||
} | ||
} |
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,82 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Nerosoft.Euonia.Bus.Tests.Commands; | ||
|
||
namespace Nerosoft.Euonia.Bus.Tests; | ||
|
||
#if DEBUG | ||
public partial class ServiceBusTests | ||
{ | ||
private readonly IBus _bus; | ||
private readonly bool _dontRunTests; | ||
|
||
public ServiceBusTests(IBus bus, IConfiguration configuration) | ||
{ | ||
_bus = bus; | ||
_dontRunTests = configuration.GetValue<bool>("DontRunTests"); | ||
} | ||
|
||
|
||
public partial async Task TestSendCommand_HasReponse() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
var result = await _bus.SendAsync<UserCreateCommand, int>(new UserCreateCommand()); | ||
Assert.Equal(1, result); | ||
} | ||
|
||
public partial async Task TestSendCommand_NoReponse() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
await _bus.SendAsync(new UserCreateCommand()); | ||
Assert.True(true); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse_UseSubscribeAttribute() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
var result = await _bus.SendAsync<FooCreateCommand, int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" }); | ||
Assert.Equal(1, result); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse_MessageHasResultInherites() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
var result = await _bus.SendAsync<int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" }); | ||
Assert.Equal(1, result); | ||
} | ||
} | ||
#else | ||
public partial class ServiceBusTests | ||
{ | ||
public partial async Task TestSendCommand_HasReponse() | ||
Check warning on line 62 in Tests/Euonia.Bus.RabbitMq.Tests/ServiceBusTests.cs GitHub Actions / build (7.0.x, Release)
|
||
{ | ||
Assert.True(true); | ||
} | ||
|
||
public partial async Task TestSendCommand_NoReponse() | ||
{ | ||
Assert.True(true); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse_UseSubscribeAttribute() | ||
{ | ||
Assert.True(true); | ||
} | ||
|
||
public partial async Task TestSendCommand_HasReponse_MessageHasResultInherites() | ||
{ | ||
Assert.True(true); | ||
} | ||
} | ||
#endif |
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 |
---|---|---|
@@ -1,60 +1,16 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Nerosoft.Euonia.Bus.Tests.Commands; | ||
namespace Nerosoft.Euonia.Bus.Tests; | ||
|
||
namespace Nerosoft.Euonia.Bus.Tests; | ||
|
||
public class ServiceBusTests | ||
public partial class ServiceBusTests | ||
{ | ||
private readonly IBus _bus; | ||
private readonly bool _dontRunTests; | ||
|
||
public ServiceBusTests(IBus bus, IConfiguration configuration) | ||
{ | ||
_bus = bus; | ||
_dontRunTests = configuration.GetValue<bool>("DontRunTests"); | ||
} | ||
|
||
[Fact] | ||
public async Task TestSendCommand_HasReponse() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
var result = await _bus.SendAsync<UserCreateCommand, int>(new UserCreateCommand()); | ||
Assert.Equal(1, result); | ||
} | ||
public partial Task TestSendCommand_HasReponse(); | ||
|
||
[Fact] | ||
public async Task TestSendCommand_NoReponse() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
await _bus.SendAsync(new UserCreateCommand()); | ||
Assert.True(true); | ||
} | ||
public partial Task TestSendCommand_NoReponse(); | ||
|
||
[Fact] | ||
public async Task TestSendCommand_HasReponse_UseSubscribeAttribute() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
var result = await _bus.SendAsync<FooCreateCommand, int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" }); | ||
Assert.Equal(1, result); | ||
} | ||
public partial Task TestSendCommand_HasReponse_UseSubscribeAttribute(); | ||
|
||
[Fact] | ||
public async Task TestSendCommand_HasReponse_MessageHasResultInherites() | ||
{ | ||
if (_dontRunTests) | ||
{ | ||
return; | ||
} | ||
var result = await _bus.SendAsync<int>(new FooCreateCommand(), new SendOptions { Channel = "foo.create" }); | ||
Assert.Equal(1, result); | ||
} | ||
public partial Task TestSendCommand_HasReponse_MessageHasResultInherites(); | ||
} |