mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using NUnit.Framework;
|
|
using System;
|
|
|
|
#if KeePassLib
|
|
using KeePassLib.Cryptography;
|
|
#else
|
|
using ModernKeePassLib.Cryptography;
|
|
#endif
|
|
|
|
namespace ModernKeePassLib.Test.Shared.Cryptography
|
|
{
|
|
[TestFixture ()]
|
|
public class CryptoRandomTests
|
|
{
|
|
[Test ()]
|
|
public void TestAddEntropy ()
|
|
{
|
|
// just making sure it does not throw an exception
|
|
CryptoRandom.Instance.AddEntropy (new byte[1]);
|
|
}
|
|
|
|
[Test ()]
|
|
public void TestGetRandomBytes ()
|
|
{
|
|
const int length = 32;
|
|
var bytes1 = CryptoRandom.Instance.GetRandomBytes (length);
|
|
Assert.That (bytes1.Length, Is.EqualTo (length));
|
|
var bytes2 = CryptoRandom.Instance.GetRandomBytes (length);
|
|
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
|
|
}
|
|
|
|
[Test ()]
|
|
public void TestGeneratedBytesCount ()
|
|
{
|
|
const int length = 1;
|
|
CryptoRandom.Instance.GetRandomBytes (length);
|
|
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
|
|
CryptoRandom.Instance.GetRandomBytes (length);
|
|
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
|
|
Assert.That (count2, Is.GreaterThan (count1));
|
|
}
|
|
}
|
|
}
|
|
|