Skip to content

Commit

Permalink
New constructor to aid in UnitTesting.
Browse files Browse the repository at this point in the history
  • Loading branch information
houseofcat committed Apr 23, 2024
1 parent 7f7c573 commit 52786f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/HouseofCat.RabbitMQ/Services/RabbitService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ public class RabbitService : IRabbitService, IDisposable

public string TimeFormat { get; set; } = TimeHelpers.Formats.RFC3339Long;

public RabbitService(
ISerializationProvider serializationProvider,
IEncryptionProvider encryptionProvider = null,
ICompressionProvider compressionProvider = null)
{
SerializationProvider = serializationProvider;
EncryptionProvider = encryptionProvider;
CompressionProvider = compressionProvider;
}

public RabbitService(
string fileNamePath,
ISerializationProvider serializationProvider,
Expand Down
10 changes: 5 additions & 5 deletions tests/UnitTests/Hashing/HashingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task Argon2ID_Hash_256bit()
var hashKey = await _provider
.GetHashKeyAsync(_passphrase, _salt, 32);

Assert.True(hashKey.Length == 32);
Assert.Equal(32, hashKey.Length);
}

[Fact]
Expand All @@ -28,7 +28,7 @@ public async Task Argon2ID_Hash_192bit()
var hashKey = await _provider
.GetHashKeyAsync(_passphrase, _salt, 24);

Assert.True(hashKey.Length == 24);
Assert.Equal(24, hashKey.Length);
}

[Fact]
Expand All @@ -37,7 +37,7 @@ public async Task Argon2ID_Hash_128bit()
var hashKey = await _provider
.GetHashKeyAsync(_passphrase, _salt, 16);

Assert.True(hashKey.Length == 16);
Assert.Equal(16, hashKey.Length);
}

[Fact]
Expand All @@ -50,14 +50,14 @@ public async Task Argon2ID_Hash_NullPassphrase()
public async Task Argon2ID_Hash_NullSalt()
{
var hashKey = await _provider.GetHashKeyAsync(_passphrase, salt: null, 16);
Assert.True(hashKey.Length == 16);
Assert.Equal(16, hashKey.Length);
}

[Fact]
public async Task Argon2ID_Hash_EmptyStringSalt()
{
var hashKey = await _provider.GetHashKeyAsync(_passphrase, salt: string.Empty, 16);
Assert.True(hashKey.Length == 16);
Assert.Equal(16, hashKey.Length);
}

[Fact]
Expand Down
2 changes: 0 additions & 2 deletions tests/UnitTests/RabbitMQ/RabbitServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public class RabbitServiceTests

public RabbitServiceTests()
{
var options = new RabbitOptions();
var hashingProvider = new ArgonHashingProvider();

var hashKey = hashingProvider.GetHashKey("Sega", "Nintendo", 32);
_encryptionProvider = new AesGcmEncryptionProvider(hashKey);
_compressionProvider = new GzipProvider();

_rabbitService = new RabbitService(
options,
new JsonProvider(),
_encryptionProvider,
_compressionProvider);
Expand Down

0 comments on commit 52786f0

Please sign in to comment.