Skip to content

Commit 915e364

Browse files
Fix flaky BlowfishEncoder tests (#428)
1 parent d656655 commit 915e364

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Algorithms.Tests/Encoders/BlowfishEncoderTests.cs

+15-13
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,39 @@ namespace Algorithms.Tests.Encoders;
88

99
public class BlowfishEncoderTests
1010
{
11-
private BlowfishEncoder _encoder = new();
12-
const string key = "aabb09182736ccdd";
13-
14-
[SetUp]
15-
public void Setup()
16-
{
17-
_encoder = new BlowfishEncoder();
18-
_encoder.GenerateKey(key);
19-
}
11+
private const string Key = "aabb09182736ccdd";
2012

2113
[Test]
2214
public void BlowfishEncoder_Encryption_ShouldWorkCorrectly()
2315
{
24-
const string plainText = "123456abcd132536";
16+
// Arrange
17+
var encoder = new BlowfishEncoder();
18+
encoder.GenerateKey(Key);
2519

20+
const string plainText = "123456abcd132536";
2621
const string cipherText = "d748ec383d3405f7";
2722

28-
var result = _encoder.Encrypt(plainText);
23+
// Act
24+
var result = encoder.Encrypt(plainText);
2925

26+
// Assert
3027
result.Should().Be(cipherText);
3128
}
3229

3330
[Test]
3431
public void BlowfishEncoder_Decryption_ShouldWorkCorrectly()
3532
{
36-
const string cipherText = "d748ec383d3405f7";
33+
// Arrange
34+
var encoder = new BlowfishEncoder();
35+
encoder.GenerateKey(Key);
3736

37+
const string cipherText = "d748ec383d3405f7";
3838
const string plainText = "123456abcd132536";
3939

40-
var result = _encoder.Decrypt(cipherText);
40+
// Act
41+
var result = encoder.Decrypt(cipherText);
4142

43+
// Assert
4244
result.Should().Be(plainText);
4345
}
4446
}

0 commit comments

Comments
 (0)