Skip to content

Commit

Permalink
Fix flaky BlowfishEncoder tests (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
KoditkarVedant authored Dec 29, 2023
1 parent d656655 commit 915e364
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Algorithms.Tests/Encoders/BlowfishEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,39 @@ namespace Algorithms.Tests.Encoders;

public class BlowfishEncoderTests
{
private BlowfishEncoder _encoder = new();
const string key = "aabb09182736ccdd";

[SetUp]
public void Setup()
{
_encoder = new BlowfishEncoder();
_encoder.GenerateKey(key);
}
private const string Key = "aabb09182736ccdd";

[Test]
public void BlowfishEncoder_Encryption_ShouldWorkCorrectly()
{
const string plainText = "123456abcd132536";
// Arrange
var encoder = new BlowfishEncoder();
encoder.GenerateKey(Key);

const string plainText = "123456abcd132536";
const string cipherText = "d748ec383d3405f7";

var result = _encoder.Encrypt(plainText);
// Act
var result = encoder.Encrypt(plainText);

// Assert
result.Should().Be(cipherText);
}

[Test]
public void BlowfishEncoder_Decryption_ShouldWorkCorrectly()
{
const string cipherText = "d748ec383d3405f7";
// Arrange
var encoder = new BlowfishEncoder();
encoder.GenerateKey(Key);

const string cipherText = "d748ec383d3405f7";
const string plainText = "123456abcd132536";

var result = _encoder.Decrypt(cipherText);
// Act
var result = encoder.Decrypt(cipherText);

// Assert
result.Should().Be(plainText);
}
}

0 comments on commit 915e364

Please sign in to comment.