mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
e6a06915cd
Codestyle fixes Setup CODEOWNERS Setup dependabot
54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
using FluentAssertions;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System.Linq;
|
|
using System.Security.Rng;
|
|
|
|
namespace SystemExtensions.NetStandard.Security.Tests;
|
|
|
|
[TestClass]
|
|
public class CryptoRngProviderTests
|
|
{
|
|
private CryptoRngProvider cryptoRngProvider;
|
|
|
|
[TestInitialize]
|
|
public void TestInitialize()
|
|
{
|
|
this.cryptoRngProvider = new CryptoRngProvider();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetBytes_ShouldSetValues()
|
|
{
|
|
var bytes = new byte[100];
|
|
|
|
this.cryptoRngProvider.GetBytes(bytes);
|
|
|
|
bytes.All(b => b == 0).Should().BeFalse();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetNonZeroBytes_ShouldSetNonZeroValues()
|
|
{
|
|
var bytes = new byte[100];
|
|
|
|
this.cryptoRngProvider.GetNonZeroBytes(bytes);
|
|
|
|
bytes.All(b => b != 0).Should().BeTrue();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetBytes_ShouldReturnBytes()
|
|
{
|
|
var bytes = this.cryptoRngProvider.GetBytes(10);
|
|
|
|
bytes.Length.Should().Be(10);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetNonZeroBytes_ShouldReturnBytes()
|
|
{
|
|
var bytes = this.cryptoRngProvider.GetNonZeroBytes(10);
|
|
|
|
bytes.Length.Should().Be(10);
|
|
}
|
|
} |