From 52786f019e8b4ff2e7a0fb5b69a4d94be38a9011 Mon Sep 17 00:00:00 2001 From: "Tristan (HouseCat) Hyams" Date: Tue, 23 Apr 2024 17:01:31 -0500 Subject: [PATCH] New constructor to aid in UnitTesting. --- src/HouseofCat.RabbitMQ/Services/RabbitService.cs | 10 ++++++++++ tests/UnitTests/Hashing/HashingTests.cs | 10 +++++----- tests/UnitTests/RabbitMQ/RabbitServiceTests.cs | 2 -- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/HouseofCat.RabbitMQ/Services/RabbitService.cs b/src/HouseofCat.RabbitMQ/Services/RabbitService.cs index 6eb0b79c..37391a53 100644 --- a/src/HouseofCat.RabbitMQ/Services/RabbitService.cs +++ b/src/HouseofCat.RabbitMQ/Services/RabbitService.cs @@ -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, diff --git a/tests/UnitTests/Hashing/HashingTests.cs b/tests/UnitTests/Hashing/HashingTests.cs index a25b3ae9..596a1c27 100644 --- a/tests/UnitTests/Hashing/HashingTests.cs +++ b/tests/UnitTests/Hashing/HashingTests.cs @@ -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] @@ -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] @@ -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] @@ -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] diff --git a/tests/UnitTests/RabbitMQ/RabbitServiceTests.cs b/tests/UnitTests/RabbitMQ/RabbitServiceTests.cs index 9438db48..47c7940a 100644 --- a/tests/UnitTests/RabbitMQ/RabbitServiceTests.cs +++ b/tests/UnitTests/RabbitMQ/RabbitServiceTests.cs @@ -16,7 +16,6 @@ public class RabbitServiceTests public RabbitServiceTests() { - var options = new RabbitOptions(); var hashingProvider = new ArgonHashingProvider(); var hashKey = hashingProvider.GetHashKey("Sega", "Nintendo", 32); @@ -24,7 +23,6 @@ public RabbitServiceTests() _compressionProvider = new GzipProvider(); _rabbitService = new RabbitService( - options, new JsonProvider(), _encryptionProvider, _compressionProvider);