Added unit tests (all passing unfortunately)

UI improvements
Write mode still doesn't work
This commit is contained in:
2017-09-25 18:34:27 +02:00
parent 34996da19d
commit 22ea657885
72 changed files with 2563 additions and 63 deletions

View File

@@ -0,0 +1,44 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using ModernKeePassLibPCL.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));
}
}
}