Removed useless Bouncy Castle package and test

Migrated to Nunit
Refactor
This commit is contained in:
Geoffroy BONNEVILLE
2019-07-29 17:30:15 +02:00
parent 26e8e5c223
commit c4de2dd594
23 changed files with 381 additions and 423 deletions

View File

@@ -1,28 +1,30 @@
using ModernKeePassLib.Cryptography;
using Xunit;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture]
public class CryptoRandomTests
{
[Fact]
[Test]
public void TestAddEntropy()
{
// just making sure it does not throw an exception
CryptoRandom.Instance.AddEntropy(new byte[1]);
Assert.DoesNotThrow(() => CryptoRandom.Instance.AddEntropy(new byte[1]));
}
[Fact]
[Test]
public void TestGetRandomBytes()
{
const int length = 32;
var bytes1 = CryptoRandom.Instance.GetRandomBytes(length);
Assert.Equal(bytes1.Length, length);
var bytes2 = CryptoRandom.Instance.GetRandomBytes(length);
Assert.NotEqual(bytes2, bytes1);
Assert.That(length, Is.EqualTo(bytes1.Length));
Assert.That(bytes1, Is.Not.EqualTo(bytes2));
}
[Fact]
[Test]
public void TestGeneratedBytesCount()
{
const int length = 1;
@@ -30,7 +32,8 @@ namespace ModernKeePassLib.Test.Cryptography
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
CryptoRandom.Instance.GetRandomBytes(length);
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
Assert.True(count2 > count1);
Assert.That(count2, Is.GreaterThan(count1));
}
}
}